-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathazure-pipelines.yml
103 lines (96 loc) · 3.67 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Docs:
# https://aka.ms/yaml
trigger:
batch: true
branches:
include:
- master
variables:
terraformVersion: 1.4.6
agentPool: 'ubuntu-latest'
action:
parameters:
- name: environment_components
type: object
default:
- environment: 'ptlsbox'
service_connection: 'DTS-CFTSBOX-INTSVC'
storage_account_rg: 'core-infra-intsvc-rg'
storage_account_name: 'cftsboxintsvc'
tfvarsFile: 'ptlsbox.tfvars'
- environment: 'ptl'
service_connection: 'DTS-CFTPTL-INTSVC'
storage_account_rg: 'core-infra-intsvc-rg'
storage_account_name: 'cftptlintsvc'
tfvarsFile: 'ptl.tfvars'
stages:
- stage: GetArtifacts
jobs:
- job: Validate
pool:
vmImage: ${{ variables.agentPool }}
steps:
- task: TerraformInstaller@0
inputs:
terraformVersion: ${{ variables.terraformVersion }}
- task: PowerShell@2
displayName: Run tests
inputs:
targetType: 'inline'
script: |
Install-Module -Name Pester -Force -MaximumVersion 4.99.99 -Verbose -Scope CurrentUser
Invoke-Pester ./ci -OutputFormat NUnitXml -OutputFile ./TEST-CI.xml -EnableExit
pwsh: true
- task: PublishTestResults@2
displayName: 'Publish Test Results **/TEST-*.xml'
inputs:
testResultsFormat: NUnit
failTaskOnFailedTests: true
condition: always()
- ${{ each component in parameters.environment_components }}:
- stage: PlanResponse_${{ component.environment }}
displayName: "Plan Response - ${{ component.environment }}"
dependsOn: GetArtifacts
jobs:
- template: pipeline-templates/terraform-plan.yaml
parameters:
environment: ${{ component.environment }}
component: 'response'
service_connection: ${{ component.service_connection }}
storage_account_rg: ${{ component.storage_account_rg }}
storage_account_name: ${{ component.storage_account_name }}
build: $(Build.BuildNumber)
agentPool: ${{ variables.agentPool }}
terraformVersion: ${{ variables.terraformVersion }}
builtFrom: $(Build.Repository.Name)
tfvarsFile: ${{ component.tfvarsFile }}
- job: Archive
dependsOn: Plan_${{ component.environment }}_response
pool:
vmImage: ${{ variables.agentPool }}
steps:
- task: CopyFiles@2
displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
inputs:
Contents: |
*.tf
*.tfvars
*tfplan
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
- stage: ApplyResponse_${{ component.environment }}
displayName: "Apply Response - ${{ component.environment }}"
dependsOn: PlanResponse_${{ component.environment }}
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
jobs:
- template: pipeline-templates/terraform-apply.yaml
parameters:
environment: ${{ component.environment }}
component: 'response'
service_connection: ${{ component.service_connection }}
storage_account_rg: ${{ component.storage_account_rg }}
storage_account_name: ${{ component.storage_account_name }}
build: $(Build.BuildNumber)
agentPool: ${{ variables.agentPool }}
terraformVersion: ${{ variables.terraformVersion }}