Untitled
unknown
yaml
2 years ago
4.0 kB
10
Indexable
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yam1
trigger:
- none
variables:
pipelineImageName: 'ubuntu-latest'
serviceConnectionName: 'Workflow-DevTest'
infrastructureSourcesFolderPath: 'Infrastructure'
infrastructureTemplateFilePath: '$(infrastructureSourcesFolderPath)/TODO'
infrastructureTemplateParametersFilePath: '$(infrastructureSourcesFolderPath)/TODO'
subscriptionId: '1fedd5f0-38e0-48c7-9dca-f895752682a9'
location: 'eastus2'
resourceGroup: 'wf-cd-3'
bkstrgrg: 'resource_group_name'
bkstrg: 'storage_account_name'
bkcontainer: 'container_name'
bkstrgkey: 'filename.key.name ex: testpipeline.terraform.tfstate'
pool:
vmImage: $(pipelineImageName) # Specify the VM image at the pipeline level
stages:
- stage: DotnetBuildTestPublish
jobs:
- job: BuildTestPublish
steps:
- task: DotNetCoreCLI@2
displayName: DotNet Restore
condition: succeeded() # Runs only if the previous stages/jobs succeeded
inputs:
command: 'restore'
projects: '**/*.csproj'
feedsToUse: 'select'
- task: DotNetCoreCLI@2
displayName: DotNet Build
condition: succeeded('BuildTestPublish.DotNet Restore') # Runs only if DotNet Restore succeeded
inputs:
command: 'build'
projects: '**/*.csproj'
arguments: '--configuration $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: DotNet Test
condition: succeeded('BuildTestPublish.DotNet Build') # Runs only if DotNet Build succeeded
inputs:
command: 'test'
projects: '**/*Tests.csproj'
arguments: '--configuration $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: DotNet Publish
condition: succeeded('BuildTestPublish.DotNet Test') # Runs only if DotNet Test succeeded
inputs:
command: 'publish'
publishWebProjects: true
zipAfterPublish: true
arguments: '--configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)'
- stage: tfvalidate
jobs:
- job: validate
continueOnError: false
steps:
- task: TerraformInstaller@0
displayName: tfinstall
inputs:
terraformVersion: 'latest'
- task: TerraformTaskV3@3
displayName: init
inputs:
provider: 'azurerm'
command: 'init'
backendServiceArm: 'DevTestServiceConnection'
backendAzureRmResourceGroupName: '$(bkstrgrg)'
backendAzureRmStorageAccountName: '$(bkstrg)'
backendAzureRmContainerName: '$(bkcontainer)'
backendAzureRmKey: '$(bkstrgkey)'
- task: TerraformTaskV3@3
displayName: validate
inputs:
provider: 'azurerm'
command: 'validate'
- stage: tfdeploy
condition: succeeded('tfvalidate')
dependsOn: tfvalidate
jobs:
- job: apply
steps:
- task: TerraformInstaller@8
displayName: tfinstall
inputs:
terraformVersion: 'latest'
- task: TerraformTaskV3@3
displayName: init
inputs:
provider: 'azurerm'
command: 'init'
backendServiceArm: 'DevTestServiceConnection'
backendAzureRmResourceGroupName: '$(bkstrgrg)'
backendAzureRmStorageAccountName: '$(bkstrg)'
backendAzureRmContainerName: '$(bkcontainer)'
backendAzureRmKey: '$(bkstrgkey)'
- task: TerraformTaskV3@3
displayName: plan
inputs:
provider: 'azurerm'
command: 'plan'
environmentServiceNameAzureRM: 'DevTestServiceConnection'
- task: TerraformTaskV3@3
displayName: apply
inputs:
provider: 'azurerm'
command: 'apply'
environmentServiceNameAzureRM: 'DevTestServiceConnection'
# TODO: deploy infrastructure
# TODO: deploy database
# TODO: deploy web app
Editor is loading...
Leave a Comment