-
Notifications
You must be signed in to change notification settings - Fork 4
/
azure-pipelines.yml
146 lines (133 loc) · 5.51 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
139
140
141
142
143
144
145
146
name: $(Build.BuildID)
trigger: none
variables:
- group: 'SonarQube as a Service'
- name: HostingPlan
value: 'asp-SonarHosting$(SuffixName)'
- name: SqlDb
value: 'sqldb-sonarhosting$(SuffixName)'
- name: SqlServer
value: 'sqlsrv-sonarhosting$(SuffixName)'
- name: Website
value: 'wa-SonarHosting$(SuffixName)'
- name: ResourceGroup
value: 'Rp-SonarQubeAsAService'
- name: SkuCapacity
value: '1'
- name: SkuSize
value: 'S1'
stages:
- stage: Build
displayName: Build Stage
jobs:
- job: Build_ARM_Phase
displayName: 'Build ARM'
pool:
vmImage: 'ubuntu-latest'
steps:
- task: AzureResourceManagerTemplateDeployment@3
displayName: 'Validate ARM Templates'
inputs:
deploymentScope: 'Resource Group'
ConnectedServiceName: '$(AzureConnectionServiceName)'
subscriptionName: '$(SubscriptionGuid)'
action: 'Create Or Update Resource Group'
resourceGroupName: '$(ResourceGroup)'
location: 'West Europe'
templateLocation: 'Linked artifact'
csmFile: 'ARM/sonar.azuredeploy.json'
csmParametersFile: 'ARM/sonar.azuredeploy.parameters.json'
overrideParameters: '-hostingPlanName "$(HostingPlan)" -webSiteName "$(Website)" -sqlserverName "$(SqlServer)" -databaseName "$(SqlDb)" -skuName "$(SkuSize)" -skuCapacity $(SkuCapacity) -sqlAdministratorLogin "$(SqlAdmin)" -sqlAdministratorLoginPassword "$(SqlAdminPassword)"'
deploymentMode: 'Validation'
- task: CopyFiles@2
displayName: 'Copy ARM Files to: AzureRessources Folder'
inputs:
SourceFolder: ARM
TargetFolder: '$(build.artifactstagingdirectory)/AzureRessources'
- publish: $(build.artifactstagingdirectory)/AzureRessources
displayName: 'Publish ARM Files'
artifact: AzureRessources
- task: CopyFiles@2
displayName: 'Copy Deploy and Run Scripts'
inputs:
Contents: |
Deploy/**/*.ps1
Run/**/*.ps1
**/sonar.properties
**/*.config
TargetFolder: '$(build.artifactstagingdirectory)/InstallScripts'
- publish: $(build.artifactstagingdirectory)/InstallScripts
displayName: 'Publish Deploy and Run Scripts'
artifact: InstallScripts
- stage: Test
displayName: Test Deployment
dependsOn: Build
jobs:
- deployment: Deploy_ARM
displayName: 'Deploy Infrastructure'
pool:
vmImage: 'vs2017-win2016'
environment: Test
strategy:
runOnce:
deploy:
steps:
- download: current
displayName: Download AzureRessources
artifact: AzureRessources
patterns: '**/*.json'
- download: current
displayName: Download InstallScripts
artifact: InstallScripts
- task: AzureResourceManagerTemplateDeployment@3
displayName: "Deploy Infrastructure"
inputs:
deploymentScope: 'Resource Group'
ConnectedServiceName: '$(AzureConnectionServiceName)'
subscriptionName: '$(SubscriptionGuid)'
action: 'Create Or Update Resource Group'
resourceGroupName: '$(ResourceGroup)'
location: 'West Europe'
templateLocation: 'Linked artifact'
csmFile: '../AzureRessources/sonar.azuredeploy.json'
csmParametersFile: '../AzureRessources/sonar.azuredeploy.parameters.json'
overrideParameters: '-hostingPlanName "$(HostingPlan)" -webSiteName "$(Website)" -sqlserverName "$(SqlServer)" -databaseName "$(SqlDb)" -skuName "$(SkuSize)" -skuCapacity $(SkuCapacity) -sqlAdministratorLogin "$(SqlAdmin)" -sqlAdministratorLoginPassword "$(SqlAdminPassword)"'
deploymentMode: 'Incremental'
- task: AzureRmWebAppDeployment@4
displayName: "Deploy Installation Scripts"
inputs:
ConnectionType: 'AzureRM'
azureSubscription: '$(AzureConnectionServiceName)'
appType: 'webApp'
WebAppName: '$(Website)'
packageForLinux: '../InstallScripts/Deploy'
enableCustomDeployment: true
DeploymentType: 'webDeploy'
- task: AzurePowerShell@4
displayName: "Install SonarQube on WebApp"
inputs:
azureSubscription: '$(AzureConnectionServiceName)'
ScriptType: 'FilePath'
ScriptPath: '../InstallScripts/Deploy/RunPowerShellKudu.ps1'
ScriptArguments: '-WebsiteName "$(Website)"'
azurePowerShellVersion: 'LatestVersion'
pwsh: true
- task: AzureRmWebAppDeployment@4
displayName: "Deploy Run Scripts"
inputs:
ConnectionType: 'AzureRM'
azureSubscription: '$(AzureConnectionServiceName)'
appType: 'webApp'
WebAppName: '$(Website)'
packageForLinux: '../InstallScripts/Run'
enableCustomDeployment: true
DeploymentType: 'webDeploy'
- task: AzurePowerShell@4
displayName: "Configure SonarQube on WebApp"
inputs:
azureSubscription: '$(AzureConnectionServiceName)'
ScriptType: 'FilePath'
ScriptPath: '../InstallScripts/Deploy/ConfigureSonar.ps1'
ScriptArguments: '-WebAppName "$(Website)" -AdminUser "$(SonarAdmin)" -AadTenantId "$(TenantId)" -AadClientId "$(SonarAppId)" -AadClientSecret "$(SonarAppSecret)"'
azurePowerShellVersion: 'LatestVersion'
pwsh: true