pipeline
unknown
plain_text
2 years ago
4.0 kB
16
Indexable
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-2'
bkstrgrg: 'wf-cd-2'
bkstrg: 'wfcd2storage'
bkcontainer: 'wf-cd-2-stgcont'
bkstrgkey: 'testpipeline.terraform.tfstate'
pool:
vmImage: $(pipelineImageName)
stages:
- stage: DotnetBuildTestPublish
jobs:
- job: BuildTestPublish
steps:
- task: DotNetCoreCLI@2
displayName: DotNet Restore
continueOnError: false
inputs:
command: 'restore'
projects: '**/*.csproj'
feedsToUse: 'select'
- task: DotNetCoreCLI@2
displayName: DotNet Build
condition: succeeded()
inputs:
command: 'build'
projects: '**/*.csproj'
arguments: '--configuration $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: DotNet Test
condition: succeeded()
inputs:
command: 'test'
projects: '**/*Tests.csproj'
arguments: '--configuration $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: DotNet Publish
condition: succeeded()
inputs:
command: 'publish'
publishWebProjects: true
zipAfterPublish: true
arguments: '--configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)'
- stage: ManageStorageAccountIP
jobs:
- job: AddIPToStorageAccount
steps:
- task: AzureCLI@2
displayName: 'Add AZDO Agent IP to Storage Account Network Rules'
inputs:
azureSubscription: $(serviceConnectionName)
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
$ip = Invoke-RestMethod http://ipinfo.io/json | Select -exp ip
$cidrip = $ip.Substring(0, $ip.LastIndexOf(".")) + ".0/24"
az storage account network-rule add --resource-group $(bkstrgrg) --account-name $(bkstrg) --ip-address $cidrip
- job: TerraformTasks
dependsOn: AddIPToStorageAccount
steps:
- task: ms-devlabs.custom-terraform-tasks.custom-terraform-installer-task.TerraformInstaller@0
displayName: tfinstall
inputs:
terraformVersion: 'latest'
- task: TerraformTaskV4@4
displayName: tfinit
inputs:
provider: 'azurerm'
command: 'init'
backendServiceArm: $(serviceConnectionName)
backendAzureRmResourceGroupName: $(bkstrgrg)
backendAzureRmStorageAccountName: $(bkstrg)
backendAzureRmContainerName: $(bkcontainer)
backendAzureRmKey: $(bkstrgkey)
workingDirectory: '$(System.DefaultWorkingDirectory)/terraform'
- task: TerraformTaskV3@3
displayName: validate
inputs:
provider: 'azurerm'
command: 'validate'
workingDirectory: '$(System.DefaultWorkingDirectory)/terraform'
- task: TerraformTaskV4@4
displayName: plan
inputs:
provider: 'azurerm'
command: 'plan'
environmentServiceNameAzureRM: $(serviceConnectionName)
workingDirectory: '$(System.DefaultWorkingDirectory)/terraform'
- job: RemoveIPFromStorageAccount
dependsOn: TerraformTasks
condition: always()
steps:
- task: AzureCLI@2
displayName: 'Remove AZDO Agent IP from Storage Account Network Rules'
inputs:
azureSubscription: $(serviceConnectionName)
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
$ip = Invoke-RestMethod http://ipinfo.io/json | Select -exp ip
az storage account network-rule remove --resource-group $(bkstrgrg) --account-name $(bkstrg) --ip-address $ip
Editor is loading...
Leave a Comment