-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
201 lines (194 loc) · 9.02 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# Conditional Azure DevOps YAML pipeline
# https://raw.githubusercontent.com/MicrosoftDocs/pipelines-multistage/master/conditional.yml
# Set Variables
variables:
- group: M365-environment-variables
# Set Name
name: $(BuildDefinitionName)_$(BuildID)_$(Date:yyyyMMdd)$(Rev:.rr)
# Only run against master
trigger:
batch: true
branches:
include:
- master
exclude:
- refs/tags/*
paths:
exclude:
- releases/*
# Don't run against PRs
pr: none
# Follow Stages
stages:
- stage: build_CI
jobs:
- job: build_CI
pool:
vmImage: 'ubuntu-latest'
steps:
- script: |
echo hello world from %MyName%
echo Agent.HomeDirectory is %CD%
workingDirectory: $(Agent.HomeDirectory)
env:
MyName: $(Agent.MachineName)
condition: and(succeeded(), eq(variables['agent.os'], 'windows_nt'))
displayName: Greeting from Windows machine
- script: |
echo hello world from $MyName
echo Agent.HomeDirectory is $PWD
workingDirectory: $(Agent.HomeDirectory)
env:
MyName: $(Agent.MachineName)
condition: and(succeeded(), in(variables['agent.os'], 'darwin', 'linux'))
displayName: Greeting from macOS or Linux machine
- task: PowerShell@2
displayName: 'Greeting from Powershell'
inputs:
targetType: 'inline'
script: |
Write-Host "Hello from PowerShell v$($PSVersionTable.PSVersion.Major)"
errorActionPreference: 'silentlyContinue'
workingDirectory: $(Agent.HomeDirectory)
pwsh: true
env:
MyName: $(Agent.MachineName)
- publish: $(System.DefaultWorkingDirectory)
artifact: drop
- stage: deploy_TEST
variables:
- group: M365-TEST-environment-variables
dependsOn: build_CI
condition: and(succeeded(), eq(variables['TEST'], 1))
jobs:
- deployment: deploy_TEST
pool:
vmImage: 'ubuntu-latest'
environment: 'microsoft-365-TEST'
strategy:
runOnce:
deploy:
steps:
- task: PowerShell@2
displayName: 'Install Modules'
inputs:
targetType: 'inline'
script: |
# Install Package Provider
Install-PackageProvider -Name NuGet -Scope CurrentUser -Force -ForceBootstrap
# Install PnP.PowerShell
$PnpModuleVersion = "1.10.0"
Install-Module -Name PnP.PowerShell -Scope "CurrentUser" -RequiredVersion $PnpModuleVersion -AllowClobber -Repository 'PSGallery' -Verbose -Force
# Install PSWSMan
if ( $env:AGENT_OS -and $env:AGENT_OS -ne "Windows_NT" ) { Install-Module -Name PSWSMan -Scope "CurrentUser" -Verbose -Force; Install-WSMan -Verbose }
errorActionPreference: 'silentlyContinue'
pwsh: true
- task: DownloadSecureFile@1 # Download a secure file to the agent machine
displayName: 'Download Certificate'
name: mycert # The name with which to reference the secure file's path on the agent, like $(mySecureFile.secureFilePath)
inputs:
secureFile: "[ORGANIZATION PREFIX]-[CLIENTID]-[ENVIRONMENT].pfx" # The file name or GUID of the secure file. ex. "MC-00000000-0000-0000-0000-000000000000-PROD.pfx"
condition: ne(variables['DSTCREDS_PFXPASS'], '')
env:
DSTCREDS_PFXPASS: $(DSTCREDS_PFXPASS) # Maps the secret variable $(DSTCREDS_PFXPASS) from 'M365-TEST-environment-variables' group
- download: current
displayName: 'Download Artifact'
artifact: drop
- task: PowerShell@2
displayName: 'Run Deploy Script'
inputs:
targetType: filePath
filePath: '$(Pipeline.Workspace)/drop/Scripts/M365/6. Deployment/Test-Deployment.ps1'
errorActionPreference: silentlyContinue
pwsh: true
workingDirectory: '$(Pipeline.Workspace)/drop/Scripts/M365/6. Deployment'
env:
DSTCREDS_PASSWORD: $(DSTCREDS_PASSWORD) # Maps the secret variable $(DSTCREDS_PASSWORD) from 'M365-TEST-environment-variables' group
DSTCREDS_THUMB: $(DSTCREDS_THUMB) # Maps the secret variable $(DSTCREDS_THUMB) from 'M365-TEST-environment-variables' group
DSTCREDS_SECRET: $(DSTCREDS_SECRET) # Maps the secret variable $(DSTCREDS_SECRET) from 'M365-TEST-environment-variables' group
DSTCREDS_PFXFILE: $(mycert.secureFilePath) # Maps the secure file path from DownloadSecureFile task
DSTCREDS_PFXPASS: $(DSTCREDS_PFXPASS) # Maps the secret variable $(DSTCREDS_PFXPASS) from 'M365-TEST-environment-variables' group
- stage: deploy_PROD
variables:
- group: M365-PROD-environment-variables
dependsOn: deploy_TEST
condition: and(succeeded(), eq(variables['RELEASE'], 1))
jobs:
- deployment: deploy_PROD
pool:
vmImage: 'ubuntu-latest'
environment: 'microsoft-365-PROD'
strategy:
runOnce:
deploy:
steps:
- task: PowerShell@2
displayName: 'Install Modules'
inputs:
targetType: 'inline'
script: |
# Install Package Provider
Install-PackageProvider -Name NuGet -Scope CurrentUser -Force -ForceBootstrap
# Install PnP.PowerShell
$PnpModuleVersion = "1.10.0"
Install-Module -Name PnP.PowerShell -Scope "CurrentUser" -RequiredVersion $PnpModuleVersion -AllowClobber -Repository 'PSGallery' -Verbose -Force
# Install PSWSMan
if ( $env:AGENT_OS -and $env:AGENT_OS -ne "Windows_NT" ) { Install-Module -Name PSWSMan -Scope "CurrentUser" -Verbose -Force; Install-WSMan -Verbose }
errorActionPreference: 'silentlyContinue'
pwsh: true
- task: DownloadSecureFile@1 # Download a secure file to the agent machine
displayName: 'Download Certificate'
name: mycert # The name with which to reference the secure file's path on the agent, like $(mySecureFile.secureFilePath)
inputs:
secureFile: "[ORGANIZATION PREFIX]-[CLIENTID]-[ENVIRONMENT].pfx" # The file name or GUID of the secure file. ex. "MC-00000000-0000-0000-0000-000000000000-PROD.pfx"
condition: ne(variables['DSTCREDS_PFXPASS'], '')
env:
DSTCREDS_PFXPASS: $(DSTCREDS_PFXPASS) # Maps the secret variable $(DSTCREDS_PFXPASS) from 'M365-PROD-environment-variables' group
- download: current
displayName: 'Download Artifact'
artifact: drop
- task: PowerShell@2
displayName: 'Run Deploy Script'
inputs:
targetType: filePath
filePath: '$(Pipeline.Workspace)/drop/Scripts/M365/6. Deployment/Test-Deployment.ps1'
errorActionPreference: silentlyContinue
pwsh: true
workingDirectory: '$(Pipeline.Workspace)/drop/Scripts/M365/6. Deployment'
env:
DSTCREDS_PASSWORD: $(DSTCREDS_PASSWORD) # Maps the secret variable $(DSTCREDS_PASSWORD) from 'M365-PROD-environment-variables' group
DSTCREDS_THUMB: $(DSTCREDS_THUMB) # Maps the secret variable $(DSTCREDS_THUMB) from 'M365-PROD-environment-variables' group
DSTCREDS_SECRET: $(DSTCREDS_SECRET) # Maps the secret variable $(DSTCREDS_SECRET) from 'M365-PROD-environment-variables' group
DSTCREDS_PFXFILE: $(mycert.secureFilePath) # Maps the secure file path from DownloadSecureFile task
DSTCREDS_PFXPASS: $(DSTCREDS_PFXPASS) # Maps the secret variable $(DSTCREDS_PFXPASS) from 'M365-PROD-environment-variables' group
- task: git-tag-on-release-task@9
displayName: 'Tag Artifacts'
inputs:
searchRegex: '(microsoft-365)_([0-9]+)_([0-9]+.[0-9]+)'
replacePattern: 'Release-$1-v$2.b$3'
- task: XplatGenerateReleaseNotes@3
displayName: 'Generate Release Notes'
inputs:
outputfile: '$(Pipeline.Workspace)/releasenotes.md'
templateLocation: 'File'
templatefile: '$(Pipeline.Workspace)/drop/Scripts/M365/6. Deployment/release-notes-template.hbs'
checkStage: true
dumpPayloadToConsole: true
dumpPayloadToFile: false
replaceFile: true
getParentsAndChildren: true
- task: WikiUpdaterTask@1
displayName: 'Add Release Notes to Wiki'
inputs:
repo: 'dev.azure.com/[ORGANIZATION]/[PROJECT]/_git/[PROJECT].wiki'
filename: 'Microsoft-365/Release-Notes-$(Build.BuildId).md'
replaceFile: true
dataIsFile: true
sourceFile: '$(Pipeline.Workspace)/releasenotes.md'
message: 'Release notes created by pipeline process'
gitname: '$(Build.RequestedFor)'
gitemail: '$(Build.RequestedForEmail)'
useAgentToken: true
localpath: '$(Pipeline.Workspace)/repo'
updateOrderFile: true
prependEntryToOrderFile: true