forked from lucianopereira86/NetCore3-Swagger
-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines.yml
138 lines (128 loc) · 4.38 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# ASP.NET
# Build and test ASP.NET projects.
# Add steps that publish symbols, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
terraformVersion : '1.1.5'
system.debug: 'true'
stages:
- stage: Build
displayName: Build
jobs:
- job: BuildCode
pool:
vmImage: 'windows-latest'
steps:
- task: DotNetCoreCLI@2
displayName: 'dotnet restore'
inputs:
command: restore
projects: '**/*.csproj'
- task: DotNetCoreCLI@2
displayName: 'Build Solution'
inputs:
projects: $(solution)
arguments: ' --no-restore --configuration $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: 'Run Publish'
inputs:
projects: '**/*.csproj'
command: publish
publishWebProjects: false
zipAfterPublish: true
arguments: ' --no-build --configuration $(buildConfiguration) -o $(Build.ArtifactStagingDirectory)'
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
- task: PublishBuildArtifacts@1
displayName: Publish Build Artifacts
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
- job: BuildInfrastructure
dependsOn:
- BuildCode
pool:
vmImage: 'windows-latest'
steps:
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifacts'
inputs:
PathtoPublish: Infrastructure
ArtifactName: Infrastructure
- task: charleszipp.azure-pipelines-tasks-terraform.azure-pipelines-tasks-terraform-installer.TerraformInstaller@0
displayName: Install terraform version $(terraformVersion)
inputs:
terraformVersion: $(terraformVersion)
- task: TerraformCLI@0
displayName: terraform init
inputs:
command: init
commandOptions: -backend=false
workingDirectory: '$(Build.SourcesDirectory)\Infrastructure'
- task: TerraformCLI@0
displayName: terraform validate
inputs:
command: validate
workingDirectory: '$(Build.SourcesDirectory)\Infrastructure'
- stage: Deploy
displayName: Deploy
jobs:
- job: Deploy
pool:
vmImage: 'windows-latest'
variables:
- group: terraform-vars
steps:
- checkout: none
- download: current
displayName: Download infrastructure
artifact: Infrastructure
- download: current
displayName: Download DeploymentPackage
artifact: drop
- task: charleszipp.azure-pipelines-tasks-terraform.azure-pipelines-tasks-terraform-installer.TerraformInstaller@0
displayName: Install terraform version $(terraformVersion)
inputs:
terraformVersion: $(terraformVersion)
- task: DownloadSecureFile@1
displayName: DownloadSecureFile
inputs:
secureFile: 'terraform.tfvars'
retryCount: 5
- task: TerraformCLI@0
displayName: terraform init
inputs:
command: init
workingDirectory: $(Pipeline.Workspace)/Infrastructure
backendType: 'azurerm'
backendServiceArm: 'vs-subscription'
backendAzureRmResourceGroupName: $(storage_account_resource_group_name)
backendAzureRmStorageAccountName: $(storage_account_name)
backendAzureRmContainerName: 'tfstate'
backendAzureRmKey: 'apim.terraform.tfstate'
- task: TerraformCLI@0
displayName: terraform plan
inputs:
command: plan
environmentServiceName: 'vs-subscription'
workingDirectory: $(Pipeline.Workspace)/Infrastructure
publishPlanResults: 'infrastructure'
commandOptions: >
-out=changes.tfplan -var-file=$(DownloadSecureFile.secureFilePath)
-var "deployment_package_path=$(Pipeline.Workspace)/drop/api.zip"
-var publisher_email=$(publisher_email)
- task: TerraformCLI@0
displayName: terraform apply
inputs:
command: apply
environmentServiceName: 'vs-subscription'
workingDirectory: $(Pipeline.Workspace)/Infrastructure
commandOptions: >
changes.tfplan