Skip to content

Instantly share code, notes, and snippets.

@nikneem
Created June 2, 2020 13:12
Show Gist options
  • Save nikneem/db3e9047be17cf7a5198d89796ef20c1 to your computer and use it in GitHub Desktop.
Save nikneem/db3e9047be17cf7a5198d89796ef20c1 to your computer and use it in GitHub Desktop.
variables:
NUGET_XMLDOC_MODE: skip
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
trigger:
- master
stages:
- stage: build
displayName: Build
- job: build_api
displayName: Build the web API
pool:
name: "Azure Pipelines"
vmImage: "windows-latest"
steps:
- task: DotNetCoreCLI@2
displayName: "Restore Packages"
inputs:
command: "restore"
projects: "**/*.csproj"
feedsToUse: "select"
- task: DotNetCoreCLI@2
displayName: Publish
inputs:
command: publish
publishWebProjects: True
arguments: "--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)/webapi-package"
zipAfterPublish: True
- task: PublishPipelineArtifact@0
displayName: "Publish Artifact: webapi-package"
inputs:
artifactName: "webapi-package"
targetPath: "$(Build.ArtifactStagingDirectory)/webapi-package"
- job: build_arm_template
displayName: Build the ARM Template
pool:
name: "Azure Pipelines"
vmImage: "windows-latest"
variables:
- group: systemx-test-api
steps:
- task: CopyFiles@2
displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)\arm-template'
inputs:
SourceFolder: [YOUR-DEPLOYMENT-PROJECT-NAME]
Contents: '**\*.json'
TargetFolder: '$(Build.ArtifactStagingDirectory)\arm-template'
- task: Npm@1
displayName: "Install JSON Lint"
inputs:
command: custom
customCommand: "install jsonlint -g"
- script: "jsonlint $(Build.ArtifactStagingDirectory)/arm-template/azuredeploy.json"
displayName: "Validate ARM Template JSON Schema"
- task: AzureResourceGroupDeployment@2
displayName: "Validate ARM Template Deployment"
inputs:
azureSubscription: "systemx-test-api"
resourceGroupName: "systemx-test-api"
location: "West Europe"
csmFile: "$(Build.ArtifactStagingDirectory)/arm-template/azuredeploy.json"
csmParametersFile: "$(Build.ArtifactStagingDirectory)/arm-template/azuredeploy.test.parameters.json"
overrideParameters: '-sqlServerAdminPassword "$(keez-test-sql-server-password)"'
deploymentMode: "Validation"
- task: PublishPipelineArtifact@1
displayName: "Publish Pipeline Artifact"
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)\arm-template'
artifact: "arm-template"
- stage: test
displayName: "Deploy to Test"
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
dependsOn:
- build
jobs:
- deployment: deploy_arm_templates_incremental
displayName: "Deploy ARM Templates Incremental"
environment: "systemx-test-api"
pool:
name: "Azure Pipelines"
vmImage: "windows-2019"
variables:
- group: systemx-test-api
strategy:
runOnce:
deploy:
steps:
- task: DownloadPipelineArtifact@0
displayName: "Download Artifact: arm-template"
inputs:
artifactName: "arm-template"
targetPath: $(System.DefaultWorkingDirectory)/arm-template
- task: AzureResourceGroupDeployment@2
displayName: "ARM template deployment"
inputs:
azureSubscription: "systemx-test-api"
resourceGroupName: "systemx-test-api"
location: "West Europe"
csmFile: "$(System.DefaultWorkingDirectory)/arm-template/azuredeploy.json"
csmParametersFile: "$(System.DefaultWorkingDirectory)/arm-template/azuredeploy.test.parameters.json"
overrideParameters: '-sqlServerAdminPassword "$(keez-test-sql-server-password)"'
deploymentMode: Incremental
- deployment: deploy_webapi
displayName: "Deploy Web API"
environment: "systemx-test-api"
dependsOn:
- deploy_arm_templates_incremental
pool:
name: "Azure Pipelines"
vmImage: "windows-2019"
strategy:
runOnce:
deploy:
steps:
- task: DownloadPipelineArtifact@0
displayName: "Download Artifact: webapi-package"
inputs:
artifactName: "webapi-package"
targetPath: $(System.DefaultWorkingDirectory)/webapi-package
- task: AzureRmWebAppDeployment@4
displayName: "API App Deploy: Keez Core API"
inputs:
azureSubscription: "systemx-test-api"
appType: web
webAppName: "test-systemx-api-app"
package: "$(System.DefaultWorkingDirectory)/webapi-package/*.zip"
- deployment: deploy_arm_templates_complete
displayName: Deploy ARM Templates Complete
environment: "systemx-test-api"
dependsOn:
- deploy_webapi
pool:
name: "Azure Pipelines"
vmImage: "windows-2019"
variables:
- group: systemx-test-api
strategy:
runOnce:
deploy:
steps:
- task: DownloadPipelineArtifact@0
displayName: "Download Artifact: arm-template"
inputs:
artifactName: "arm-template"
targetPath: $(System.DefaultWorkingDirectory)/arm-template
- task: AzureResourceGroupDeployment@2
displayName: "ARM template deployment"
inputs:
azureSubscription: "systemx-test-api"
resourceGroupName: "systemx-test-api"
location: "West Europe"
csmFile: "$(System.DefaultWorkingDirectory)/arm-template/azuredeploy.json"
csmParametersFile: "$(System.DefaultWorkingDirectory)/arm-template/azuredeploy.test.parameters.json"
overrideParameters: '-sqlServerAdminPassword "$(keez-test-sql-server-password)"'
deploymentMode: Complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment