-
Notifications
You must be signed in to change notification settings - Fork 8
/
azure-pipelines.yml
127 lines (116 loc) · 4.37 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
name: "0.1$(Rev:.r)"
trigger:
branches:
include:
- "*"
paths:
include:
- /
exclude:
- /PSAksDeployment/PSAksDeployment.psd1
jobs:
- job: build_windows_2016
displayName: Build on Windows 2016 agent
timeoutInMinutes: 90
pool:
vmImage: 'vs2017-win2016'
variables:
module_name: PSAksDeployment
deploy_cluster_location: North Europe
deploy_log_analytics_location: West Europe
deploy_cluster_name: psaks-ci-$(Build.BuildId)
deploy_resource_group: psaks-ci-$(Build.BuildId)-rg
deploy_node_count: 2
deploy_node_size: D_2vCPU_8GB
deploy_letsEncrypt_email: ci-$(Build.BuildId)@gmail.com
output_folder: $(Build.BinariesDirectory)
github_user: MathieuBuisson
steps:
- powershell: |
Install-PackageProvider -Name NuGet -Force -Scope CurrentUser
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
Install-Module -Name 'Pester' -Scope CurrentUser -Force -SkipPublisherCheck
Install-Module -Name 'Az.Profile' -Scope CurrentUser -Force -AllowClobber
Install-Module -Name 'Az.Resources' -Scope CurrentUser -Force -AllowClobber
Install-Module -Name 'Az.Aks' -Scope CurrentUser -Force -AllowClobber
displayName: Install Build Dependencies
name: installDependencies
workingDirectory: $(Build.SourcesDirectory)
failOnStderr: true
- powershell: ./BuildScripts/Invoke-PesterTests.ps1 -TestSuite Unit
displayName: Run Unit Tests
name: unitTests
workingDirectory: $(Build.SourcesDirectory)
failOnStderr: true
- powershell: |
Import-Module './$(module_name)/$(module_name).psd1' -Force
Install-PSAksPrerequisites -InstallationFolder '$(output_folder)'
$DeployParams = @{
Subscription = "$Env:DEPLOY_SUBSCRIPTION"
ClusterLocation = '$(deploy_cluster_location)'
LogAnalyticsWorkspaceLocation = '$(deploy_log_analytics_location)'
ServicePrincipalID = "$Env:DEPLOY_SP_ID"
ServicePrincipalSecret = "$Env:DEPLOY_SP_SECRET"
AzureTenantID = "$Env:DEPLOY_TENANT_ID"
ClusterName = '$(deploy_cluster_name)'
NodeCount = $(deploy_node_count)
NodeSize = '$(deploy_node_size)'
LetsEncryptEmail = '$(deploy_letsEncrypt_email)'
TerraformOutputFolder = '$(output_folder)'
}
Invoke-PSAksDeployment @DeployParams
displayName: Run a Deployment
name: deployment
workingDirectory: $(Build.SourcesDirectory)
failOnStderr: true
env:
DEPLOY_SUBSCRIPTION: $(deploy_subscription)
DEPLOY_SP_ID: $(deploy_sp_id)
DEPLOY_SP_SECRET: $(deploy_sp_secret)
DEPLOY_TENANT_ID: $(deploy_tenant_id)
- powershell: ./BuildScripts/Invoke-PesterTests.ps1 -TestSuite System
displayName: Run System Tests
name: systemTests
workingDirectory: $(Build.SourcesDirectory)
failOnStderr: true
- powershell: |
Import-Module './$(module_name)/$(module_name).psd1' -Force
$RemoveParams = @{
AzureTenantID = "$Env:DEPLOY_TENANT_ID"
ServicePrincipalID = "$Env:DEPLOY_SP_ID"
ServicePrincipalSecret = "$Env:DEPLOY_SP_SECRET"
Subscription = "$Env:DEPLOY_SUBSCRIPTION"
ClusterName = '$(deploy_cluster_name)'
}
Remove-PSAksDeployment @RemoveParams
Remove-Item -Path './$(module_name)/TerraformConfigs/*/.terraform' -Recurse -Force -Confirm:$False
displayName: Cleanup Deployment
name: cleanupDeployment
workingDirectory: $(Build.SourcesDirectory)
failOnStderr: true
env:
DEPLOY_SUBSCRIPTION: $(deploy_subscription)
DEPLOY_SP_ID: $(deploy_sp_id)
DEPLOY_SP_SECRET: $(deploy_sp_secret)
DEPLOY_TENANT_ID: $(deploy_tenant_id)
- task: PublishTestResults@2
displayName: Publish Test Results
inputs:
testRunner: NUnit
testResultsFiles: '*TestResults.xml'
searchFolder: '$(Common.TestResultsDirectory)'
mergeTestResults: true
testRunTitle: 'CI Tests'
- powershell: ./BuildScripts/Push-NewModuleVersion.ps1 -NewVersion $(Build.BuildNumber)
displayName: Update Module Version
name: updateModuleVersion
workingDirectory: $(Build.SourcesDirectory)
failOnStderr: false
env:
GITHUB_PAT: $(github_pat)
EMAIL_ADDRESS: $(email_address)
- task: PublishBuildArtifacts@1
displayName: Publish Module as Artifact
inputs:
PathtoPublish: $(module_name)
ArtifactName: $(module_name)