221 lines
8.9 KiB
YAML
221 lines
8.9 KiB
YAML
parameters:
|
|
- name: target_environment
|
|
displayName: Target Environment
|
|
type: string
|
|
default: qa
|
|
values:
|
|
- qa
|
|
- uat
|
|
- prd
|
|
- name: k8s_namespace
|
|
displayName: K8s Namespace to deploy to
|
|
type: string
|
|
default: landmarkcu
|
|
values:
|
|
- landmarkcu
|
|
variables:
|
|
- template: ./config-files/${{ parameters.target_environment }}-pvars.yaml
|
|
- name: source_branch_name
|
|
value: $[replace(replace(variables['Build.SourceBranch'], 'refs/heads/', ''), '/', '-')]
|
|
- name: docker_container_repository_name
|
|
value: landmarkcu/lcu.api.internal.loanrate-loanrate
|
|
- name: buildConfiguration
|
|
${{ if or(eq(variables['Build.SourceBranchName'], 'main'), eq(variables['Build.SourceBranchName'], 'develop')) }}:
|
|
value: Release
|
|
${{ else }}:
|
|
value: Debug
|
|
|
|
resources:
|
|
repositories:
|
|
- repository: azdo_pipeline_templates
|
|
type: git
|
|
name: Infrastructure Platform/azdo-pipeline-templates
|
|
ref: main
|
|
|
|
stages:
|
|
|
|
# Restore/Build NuGet packages and push evaluation dacpac artifact to staging directory
|
|
- stage: dotnet_nuget
|
|
displayName: Restore / Build / Upload Nuget packages
|
|
jobs:
|
|
- job: build_and_push
|
|
displayName: Dotnet Nuget
|
|
pool:
|
|
name: $(pvar_azdo_agent_pool_nuget)
|
|
demands:
|
|
- msbuild
|
|
steps:
|
|
- task: DotNetCoreCLI@2
|
|
displayName: Nuget Restore
|
|
inputs:
|
|
command: 'restore'
|
|
feedsToUse: 'select'
|
|
projects: '**/*.csproj'
|
|
vstsFeed: 'LCU-Internal'
|
|
|
|
- task: DotNetCoreCLI@2
|
|
displayName: Nuget Build
|
|
inputs:
|
|
command: 'build'
|
|
projects: '**/*.csproj'
|
|
arguments: '--configuration ${{ variables.buildConfiguration }}'
|
|
|
|
- publish: './LCU.API.Internal.LoanRate/bin/${{ variables.buildConfiguration }}/LCU.Library.Internal.LcuEvaluationSql.dacpac'
|
|
artifact: Evaluation_Dacpac
|
|
|
|
- task: DotNetCoreCLI@2
|
|
displayName: Nuget Test
|
|
inputs:
|
|
command: test
|
|
projects: '**/*Tests.csproj'
|
|
arguments: '--configuration ${{ variables.buildConfiguration }} --collect "Code coverage"'
|
|
|
|
- ${{ if eq(variables['Build.SourceBranchName'], 'main') }}:
|
|
- task: NuGetCommand@2
|
|
displayName: NuGet Push
|
|
inputs:
|
|
command: 'push'
|
|
packagesToPush: '$(Pipeline.Workspace)/**/*.nupkg'
|
|
publishVstsFeed: 'LCU-Internal'
|
|
allowPackageConflicts: true
|
|
|
|
# Deploy Evaluation dacpac
|
|
- ${{ if or(eq(variables['Build.SourceBranchName'], 'develop'), eq(variables['Build.SourceBranchName'], 'main')) }}:
|
|
- stage: DB_CD_Evaluation_Dacpac
|
|
displayName: Deploy Evaluation db changes
|
|
dependsOn:
|
|
- dotnet_nuget
|
|
jobs:
|
|
- deployment: db_deploy
|
|
displayName: Deploy DB dacpac
|
|
pool: $(pvar_azdo_agent_pool_db)
|
|
environment:
|
|
name: $(pvar_azdo_deployment_environment_db)
|
|
resourceType: virtualMachine
|
|
tags: sqldb
|
|
strategy:
|
|
runOnce:
|
|
deploy:
|
|
steps:
|
|
|
|
- task: Powershell@2
|
|
displayName: Output Run Info
|
|
inputs:
|
|
targetType: inline
|
|
script: |
|
|
Write-Host "##vso[task.logissue type=warning] Deploying to SQL Server: $(pvar_loanrate_sql_server_name)"
|
|
Write-Host "##vso[task.logissue type=warning] Altering database: $(pvar_loanrate_db_name)"
|
|
|
|
- download: current
|
|
artifact: Evaluation_Dacpac
|
|
|
|
- task: SqlDacpacDeploymentOnMachineGroup@0
|
|
displayName: 'Deploy dacpac'
|
|
inputs:
|
|
DacpacFile: '$(Pipeline.Workspace)/Evaluation_Dacpac/LCU.Library.Internal.LcuEvaluationSql.dacpac'
|
|
ServerName: $(pvar_loanrate_sql_server_name)
|
|
DatabaseName: $(pvar_loanrate_db_name)
|
|
|
|
# Build LoanRate dacpac
|
|
- stage: DB_CI_LoanRate_Dacpac
|
|
dependsOn: dotnet_nuget
|
|
jobs:
|
|
- job: db_build_push
|
|
displayName: DB dacpac - Build
|
|
pool:
|
|
name: $(pvar_azdo_agent_pool_db)
|
|
demands:
|
|
- SqlPackage
|
|
- MSBuild
|
|
steps:
|
|
- task: DownloadPipelineArtifact@2
|
|
inputs:
|
|
buildType: 'current'
|
|
artifactName: Evaluation_Dacpac
|
|
itemPattern: "*.dacpac"
|
|
targetPath: './LCU.API.Internal.LoanRate/bin/${{ variables.buildConfiguration }}/'
|
|
|
|
- task: MSBuild@1
|
|
displayName: Build sql project
|
|
inputs:
|
|
solution: './LCU.API.Internal.LoanRateSql/LCU.API.Internal.LoanRateSql.sqlproj'
|
|
configuration: '${{ variables.buildConfiguration }}'
|
|
|
|
- ${{ if or(eq(variables['Build.SourceBranchName'], 'main'), eq(variables['Build.SourceBranchName'], 'develop')) }}:
|
|
- publish: './LCU.API.Internal.LoanRateSql/bin/${{ variables.buildConfiguration }}/LCU.API.Internal.LoanRateSql.dacpac'
|
|
artifact: LoanRate_Dacpac
|
|
|
|
# Deploy LoanRate dacpac
|
|
- ${{ if or(eq(variables['Build.SourceBranchName'], 'main'), eq(variables['Build.SourceBranchName'], 'develop')) }}:
|
|
- stage: DB_CD_LoanRate_Dacpac
|
|
displayName: Deploy DB changes
|
|
variables:
|
|
- name: dacpac_file_name
|
|
value: ${{ split(format('./{0}', './LCU.API.Internal.LoanRateSql/bin/${{ variables.buildConfiguration }}/LCU.API.Internal.LoanRateSql.dacpac'),'/')[length(split('./LCU.API.Internal.LoanRateSql/bin/${{ variables.buildConfiguration }}/LCU.API.Internal.LoanRateSql.dacpac','/'))] }}
|
|
dependsOn:
|
|
- DB_CI_LoanRate_Dacpac
|
|
jobs:
|
|
- deployment: db_deploy
|
|
displayName: Deploy DB dacpac
|
|
pool: $(pvar_azdo_agent_pool_db)
|
|
environment:
|
|
name: $(pvar_azdo_deployment_environment_db)
|
|
resourceType: virtualMachine
|
|
tags: sqldb
|
|
strategy:
|
|
runOnce:
|
|
deploy:
|
|
steps:
|
|
- task: Powershell@2
|
|
displayName: Output Run Info
|
|
inputs:
|
|
targetType: inline
|
|
script: |
|
|
Write-Host "##vso[task.logissue type=warning] Deploying to SQL Server: $(pvar_loanrate_sql_server_name)"
|
|
Write-Host "##vso[task.logissue type=warning] Altering database: $(pvar_loanrate_db_name)"
|
|
|
|
- download: current
|
|
artifact: LoanRate_Dacpac
|
|
|
|
- task: SqlDacpacDeploymentOnMachineGroup@0
|
|
displayName: 'Deploy dacpac'
|
|
inputs:
|
|
DacpacFile: '$(Pipeline.Workspace)/LoanRate_Dacpac/${{ variables.dacpac_file_name }}'
|
|
ServerName: $(pvar_loanrate_sql_server_name)
|
|
DatabaseName: $(pvar_loanrate_db_name)
|
|
|
|
# Build and deploy LoanRateLoadTest dacpac
|
|
- template: db-build-deploy.yaml@azdo_pipeline_templates
|
|
parameters:
|
|
azdo_agent_pool: $(pvar_azdo_agent_pool_db)
|
|
azdo_deployment_environment: $(pvar_azdo_deployment_environment_db)
|
|
sql_project_path: './LCU.API.Internal.LoanRateLoadTestingSql/LCU.API.Internal.LoanRateLoadTestingSql.sqlproj'
|
|
built_sql_dacpac_file_path: './LCU.API.Internal.LoanRateLoadTestingSql/bin/${{ variables.buildConfiguration }}/LCU.API.Internal.LoanRateLoadTestingSql.dacpac'
|
|
name_of_artifact: loanrateloadtest_dacpac
|
|
db_name: $(pvar_loanrate_loadtest_db_name)
|
|
sql_server_name: $(pvar_loanrate_loadtest_sql_server_name)
|
|
|
|
# DOCKER BUILD AND PUSH
|
|
- template: docker-build-push.yaml@azdo_pipeline_templates
|
|
parameters:
|
|
azdo_agent_pool: $(pvar_azdo_agent_pool)
|
|
docker_registry_service_connection: $(pvar_docker_registry_service_connection)
|
|
docker_container_repository_name: $(docker_container_repository_name)
|
|
dockerfile_path: ./Dockerfile
|
|
docker_image_tags: |
|
|
build-$(Build.BuildId)
|
|
$(source_branch_name)
|
|
|
|
# K8S DEPLOY
|
|
- template: k8s-deploy.yaml@azdo_pipeline_templates
|
|
parameters:
|
|
dependsOn: CI
|
|
condition: or(eq(variables['Build.SourceBranchName'], 'develop'), eq(variables['Build.SourceBranchName'], 'main'))
|
|
azdo_agent_pool: $(pvar_azdo_agent_pool)
|
|
kubectl_version: $(pvar_kubectl_version)
|
|
k8s_service_connection: $(pvar_k8s_service_connection)
|
|
k8s_namespace: ${{ parameters.k8s_namespace }}
|
|
k8s_kustomization_path: ./kustomize/overlays/${{ parameters.target_environment }}
|
|
docker_registry_service_connection: $(pvar_docker_registry_service_connection)
|
|
docker_image_to_deploy: $(docker_container_repository_name):build-$(Build.BuildId)
|