Skip to content

Commit

Permalink
Implment YAML work
Browse files Browse the repository at this point in the history
  • Loading branch information
furqanagwan committed Jan 5, 2025
1 parent 5fa6496 commit 5e529ee
Show file tree
Hide file tree
Showing 3 changed files with 263 additions and 101 deletions.
235 changes: 134 additions & 101 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,128 +1,161 @@
parameters:
- name: OverrideBlockOnPossibleDataLoss
displayName: Add /p:BlockOnPossibleDataLoss=false argument to DACPAC deployment
type: boolean
default: false

trigger:
batch: true
branches:
include:
- "master"

variables:
- group: BUILD Management Resources
- group: ESFA - SonarCloud
- name: buildConfiguration
value: 'release'
- name: buildPlatform
value: 'anycpu'
- name: SolutionBaseName
value: SFA.DAS.ApplyService
- name: BuildConfiguration
value: release
- name: BuildPlatform
value: any cpu
- group: RELEASE Management Resources
- group: RELEASE das-apply-service
- name: Deploy
value: $[or(eq(variables['Build.SourceBranch'], 'refs/heads/main'), eq(variables['Build.Reason'], 'Manual'), eq(variables['Build.Reason'], 'PullRequest'))]


resources:
repositories:
- repository: self
- repository: das-platform-building-blocks
type: github
name: SkillsFundingAgency/das-platform-building-blocks
ref: refs/tags/2.1.28
endpoint: SkillsFundingAgency
- repository: das-platform-automation
type: github
name: SkillsFundingAgency/das-platform-automation
ref: refs/tags/5.1.14
endpoint: SkillsFundingAgency
pipelines:
- pipeline: das-employer-config
project: Digital Apprenticeship Service
source: das-employer-config
branch: master

stages:
- stage: Build
jobs:
- job: 'CodeBuild'
pool:
name: DAS - Continuous Integration Agents
demands: LATEST_DOTNET_VERSION -equals 3.1
workspace:
clean: all
steps:
- template: azure-pipelines-templates/build/step/gitversion.yml@das-platform-building-blocks

- template: azure-pipelines-templates/build/step/app-build.yml@das-platform-building-blocks
parameters:
SonarCloudProjectKey: SkillsFundingAgency_das-apply-service
ContinueOnVulnerablePackageScanError: true

- task: DotNetCoreCLI@2
displayName: 'dotnet pack'
inputs:
command: pack
packagesToPack: 'src/SFA.DAS.ApplyService.Types/SFA.DAS.ApplyService.Types.csproj'
versioningScheme: byBuildNumber
packDirectory: $(build.artifactstagingdirectory)/NugetPackages
- template: pipeline-templates/job/code-build.yml
parameters:
SolutionBaseName: $(SolutionBaseName)
BuildConfiguration: $(BuildConfiguration)
- template: azure-pipelines-templates/build/job/dacpac-template.yml@das-platform-building-blocks
parameters:
SolutionBaseName: $(SolutionBaseName)
DatabaseProjectPath: src/$(SolutionBaseName).Database/$(SolutionBaseName).Database.sqlproj

- task: DotNetCoreCLI@2
displayName: 'Publish Website'
inputs:
command: publish
publishWebProjects: false
projects: 'src/SFA.DAS.ApplyService.Web/SFA.DAS.ApplyService.Web.csproj'
arguments: '--configuration $(buildConfiguration) --output $(build.artifactstagingdirectory)/publish --no-restore --no-build'
- stage: Deploy_AT
dependsOn: Build
displayName: Deploy to AT
condition: and(succeeded(), eq(variables.Deploy, 'true'))
variables:
- group: DevTest Management Resources
- group: AT DevTest Shared Resources
- group: AT das-apply-service
jobs:
- template: pipeline-templates/job/deploy.yml
parameters:
Environment: AT
SolutionBaseName: $(SolutionBaseName)
ServiceConnection: SFA-DAS-DevTest-ARM
OverrideBlockOnPossibleDataLoss: ${{ parameters.OverrideBlockOnPossibleDataLoss }}

- task: DotNetCoreCLI@2
displayName: 'Publish API'
inputs:
command: publish
publishWebProjects: false
projects: 'src/SFA.DAS.ApplyService.InternalApi/SFA.DAS.ApplyService.InternalApi.csproj'
arguments: '--configuration $(buildConfiguration) --output $(build.artifactstagingdirectory)/publish --no-restore --no-build'
- stage: Deploy_TEST
dependsOn: Build
displayName: Deploy to TEST
variables:
- group: DevTest Management Resources
- group: TEST DevTest Shared Resources
- group: TEST das-apply-service
jobs:
- template: pipeline-templates/job/deploy.yml
parameters:
Environment: TEST
SolutionBaseName: $(SolutionBaseName)
ServiceConnection: SFA-DAS-DevTest-ARM
OverrideBlockOnPossibleDataLoss: ${{ parameters.OverrideBlockOnPossibleDataLoss }}

- task: CopyFiles@2
displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
inputs:
contents: |
azure/**
targetFolder: '$(build.artifactstagingdirectory)/publish'
- stage: Deploy_TEST2
dependsOn: Build
displayName: Deploy to TEST2
variables:
- group: DevTest Management Resources
- group: TEST2 DevTest Shared Resources
- group: TEST2 das-apply-service
jobs:
- template: pipeline-templates/job/deploy.yml
parameters:
Environment: TEST2
SolutionBaseName: $(SolutionBaseName)
ServiceConnection: SFA-DAS-DevTest-ARM
OverrideBlockOnPossibleDataLoss: ${{ parameters.OverrideBlockOnPossibleDataLoss }}

- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact'
inputs:
pathtoPublish: '$(build.artifactstagingdirectory)/publish'
- stage: Deploy_PP
dependsOn: Build
displayName: Deploy to PP
variables:
- group: PreProd Management Resources
- group: PreProd Shared Resources
- group: PREPROD das-apply-service
jobs:
- template: pipeline-templates/job/deploy.yml
parameters:
Environment: PP
SolutionBaseName: $(SolutionBaseName)
ServiceConnection: SFA-DIG-PreProd-ARM
OverrideBlockOnPossibleDataLoss: ${{ parameters.OverrideBlockOnPossibleDataLoss }}

- publish: $(build.artifactstagingdirectory)/NugetPackages
artifact: NugetPackages
- stage: Deploy_PROD
dependsOn: Build
displayName: Deploy to PROD
variables:
- group: PROD Management Resources
- group: PROD Shared Resources
- group: PROD das-apply-service
jobs:
- template: pipeline-templates/job/deploy.yml
parameters:
Environment: PROD
SolutionBaseName: $(SolutionBaseName)
ServiceConnection: SFA-DIG-Prod-ARM
OverrideBlockOnPossibleDataLoss: ${{ parameters.OverrideBlockOnPossibleDataLoss }}

- job: 'DACPACBuild'
pool:
vmImage: 'windows-2019'
workspace:
clean: all
steps:
- task: VSBuild@1
displayName: 'Build DACPAC'
inputs:
solution: 'src/SFA.DAS.ApplyService.Database/SFA.DAS.ApplyService.Database.sqlproj'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
msbuildArgs: '/p:PackageLocation="$(build.artifactstagingdirectory)/publish"'
- task: CopyFiles@2
displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
inputs:
contents: |
src/**/*.dacpac
targetFolder: '$(build.artifactstagingdirectory)/publish'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact'
inputs:
pathtoPublish: '$(build.artifactstagingdirectory)/publish'
- stage: Deploy_MO
dependsOn: Build
displayName: Deploy to MO
variables:
- group: MO Management Resources
- group: MO Shared Resources
- group: MO das-apply-service
jobs:
- template: pipeline-templates/job/deploy.yml
parameters:
Environment: MO
SolutionBaseName: $(SolutionBaseName)
ServiceConnection: SFA-ASM-ModelOffice-ARM
OverrideBlockOnPossibleDataLoss: ${{ parameters.OverrideBlockOnPossibleDataLoss }}

- stage: NugetPublish
displayName: 'Publish Nuget Package'
pool:
name: 'DAS - Continuous Deployment Agents'
condition: and(succeeded(), eq(variables['Build.Reason'], 'Manual'))
- stage: Deploy_DEMO
dependsOn: Build
displayName: Deploy to DEMO
variables:
- group: DevTest Management Resources
- group: DEMO DevTest Shared Resources
- group: DEMO das-apply-service
jobs:
- job: 'CleanArtifacts'
displayName: Clean artifacts directory
workspace:
clean: all
- deployment: 'NugetPush'
dependsOn: 'CleanArtifacts'
environment: 'Nuget'
strategy:
runOnce:
deploy:
steps:
- download: current
artifact: NugetPackages
- task: NuGetCommand@2
displayName: 'NuGet push'
inputs:
command: push
packagesToPush: '$(Pipeline.Workspace)/NugetPackages/*.nupkg;!$(Pipeline.Workspace)/NugetPackages/*.symbols.nupkg'
nuGetFeedType: external
publishFeedCredentials: 'SFA NuGet'
- template: pipeline-templates/job/deploy.yml
parameters:
Environment: DEMO
SolutionBaseName: $(SolutionBaseName)
ServiceConnection: SFA-DAS-DevTest-ARM
OverrideBlockOnPossibleDataLoss: ${{ parameters.OverrideBlockOnPossibleDataLoss }}
56 changes: 56 additions & 0 deletions pipeline-templates/job/code-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
parameters:
SolutionBaseName:
BuildConfiguration:

jobs:
- job: CodeBuild
pool:
name: DAS - Continuous Integration Agents
workspace:
clean: all
variables:
- group: BUILD Management Resources
steps:
- template: azure-pipelines-templates/build/step/gitversion.yml@das-platform-building-blocks
- template: azure-pipelines-templates/build/step/app-build.yml@das-platform-building-blocks
parameters:
SonarCloudProjectKey: SkillsFundingAgency_das-apply-service
ContinueOnVulnerablePackageScanError: true

- task: DotNetCoreCLI@2
displayName: 'Pack Types'
inputs:
command: pack
packagesToPack: 'src/SFA.DAS.ApplyService.Types/SFA.DAS.ApplyService.Types.csproj'
versioningScheme: byBuildNumber
packDirectory: $(build.artifactstagingdirectory)/NugetPackages

- task: DotNetCoreCLI@2
displayName: 'Publish Website'
inputs:
command: publish
publishWebProjects: false
projects: src/${{ parameters.SolutionBaseName }}.Web/${{ parameters.SolutionBaseName }}.Web.csproj
arguments: -o $(build.artifactstagingdirectory)/publish -c ${{ parameters.BuildConfiguration }} --no-build

- task: DotNetCoreCLI@2
displayName: 'Publish API'
inputs:
command: publish
publishWebProjects: false
projects: src/${{ parameters.SolutionBaseName }}.InternalApi/${{ parameters.SolutionBaseName }}.InternalApi.csproj
arguments: '--configuration $(buildConfiguration) --output $(build.artifactstagingdirectory)/publish --no-restore --no-build'

- task: CopyFiles@2
displayName: Copy Files to $(build.artifactstagingdirectory)/publish
inputs:
Contents: |
azure/**
TargetFolder: $(build.artifactstagingdirectory)/publish
OverWrite: true

- task: PublishPipelineArtifact@1
displayName: Publish Build Artifact
inputs:
targetPath: $(build.artifactstagingdirectory)/publish
artifactName: ${{ parameters.SolutionBaseName }}
73 changes: 73 additions & 0 deletions pipeline-templates/job/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
parameters:
ServiceConnection:
SolutionBaseName:
Environment:
OverrideBlockOnPossibleDataLoss:

jobs:
- deployment: DeployApps
pool:
name: DAS - Continuous Deployment Agents
environment: ${{ parameters.Environment }}
strategy:
runOnce:
deploy:
steps:
- template: azure-pipelines-templates/deploy/step/wait-azure-devops-deployment.yml@das-platform-building-blocks
parameters:
ServiceConnection: ${{ parameters.ServiceConnection }}
EnvironmentId: $(Environment.Id)
PipelineName: $(Build.DefinitionName)
RunId: $(Build.BuildId)
- template: azure-pipelines-templates/deploy/step/set-backendaccessrestrictions-variable.yml@das-platform-building-blocks
parameters:
ServiceConnection: ${{ parameters.ServiceConnection }}
SharedEnvResourceGroup: $(SharedEnvResourceGroup)
SharedEnvVirtualNetworkName : $(SharedEnvVirtualNetworkName)
BackEndAccessRestrictionsExcludedSubnets: $(BackEndAccessRestrictionsExcludedSubnets)
ResourceEnvironmentName: $(ResourceEnvironmentName)
UnrestrictedEnvironments: $(UnrestrictedEnvironments)
UptimeMonitoringAccessRestrictions: $(UptimeMonitoringAccessRestrictions)
- template: azure-pipelines-templates/deploy/step/arm-deploy.yml@das-platform-building-blocks
parameters:
ServiceConnection: ${{ parameters.ServiceConnection }}
SubscriptionId: $(SubscriptionId)
Location: $(ResourceGroupLocation)
Environment: ${{ parameters.Environment }}
TemplatePath: $(Pipeline.Workspace)/${{ parameters.SolutionBaseName }}/azure/template.json
ParametersPath: $(Pipeline.Workspace)/${{ parameters.SolutionBaseName }}/azure/template.parameters.json
IsMultiRepoCheckout: true
TemplateSecrets:
LoggingRedisConnectionString: $(LoggingRedisConnectionString)
ConfigurationStorageConnectionString: $(ConfigurationStorageConnectionString)
- template: azure-pipelines-templates/deploy/step/generate-config.yml@das-platform-building-blocks
parameters:
EnvironmentName: $(EnvironmentName)
ServiceConnection: ${{ parameters.ServiceConnection }}
SourcePath: $(Pipeline.Workspace)/das-employer-config/Configuration/das-apply-service
StorageAccountName: $(ConfigurationStorageAccountName)
StorageAccountResourceGroup: $(SharedEnvResourceGroup)
TargetFileName: '*.schema.json'
TableName: Configuration
ConfigurationSecrets:
SqlConnectionstring: $(SqlConnectionstring)
- template: azure-pipelines-templates/deploy/step/sql-dacpac-deploy.yml@das-platform-building-blocks
parameters:
AzureSubscription: ${{ parameters.ServiceConnection }}
ServerName: $(SharedSQLServerFQDN)
SqlUsername: $(SharedSQLServerUsername)
SqlPassword: $(SharedSQLServerPassword)
DacpacFile: $(Pipeline.Workspace)/DacpacArtifact/src/${{ parameters.SolutionBaseName }}.Database/bin/Output/${{ parameters.SolutionBaseName }}.Database.dacpac
DatabaseName: $(DatabaseName)
OverrideBlockOnPossibleDataLoss: ${{ parameters.OverrideBlockOnPossibleDataLoss }}
Environment: ${{ parameters.Environment }}
- template: azure-pipelines-templates/deploy/step/app-deploy.yml@das-platform-building-blocks
parameters:
ServiceConnection: ${{ parameters.ServiceConnection }}
AppServiceName: $(AppServiceName)
DeploymentPackagePath: $(Pipeline.Workspace)/${{ parameters.SolutionBaseName }}/${{ parameters.SolutionBaseName }}.Api.zip
- template: azure-pipelines-templates/deploy/step/app-deploy.yml@das-platform-building-blocks
parameters:
ServiceConnection: ${{ parameters.ServiceConnection }}
AppServiceName: $(AppServiceName)
DeploymentPackagePath: $(Pipeline.Workspace)/${{ parameters.SolutionBaseName }}/${{ parameters.SolutionBaseName }}.Web.zip

0 comments on commit 5e529ee

Please sign in to comment.