-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
316 lines (271 loc) · 10.2 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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
name: $(Build.BuildID)
trigger:
- master
resources:
- repo: self
variables:
Folder: 'dist'
TEAM_CIBUILD: 'true'
PESTER_VERSION: '5.0.2'
stages:
- stage: Build
displayName: Build Stage
jobs:
- job: macOS_Linux_Phase
displayName: 'Build'
strategy:
matrix:
macOS:
OS: 'macOS'
vmImageName: 'macOS-latest'
Linux:
OS: 'Linux'
vmImageName: 'ubuntu-16.04'
maxParallel: 2
pool:
vmImage: $(vmImageName)
steps:
- template: build/unitTests.yml
parameters:
os: '$(OS)'
- job: Windows_Phase
displayName: Build Windows
pool:
vmImage: 'windows-latest'
steps:
- template: build/unitTests.yml
parameters:
os: 'Windows'
buildHelp: 'true'
- task: PowerShell@2
displayName: 'Install PSScriptAnalyzer'
inputs:
targetType: 'inline'
script: 'Install-Module -Name PSScriptAnalyzer -Repository PSGallery -Force -Scope CurrentUser -Verbose'
- task: PowerShell@2
enabled: false
displayName: 'Run Static Code Analysis'
inputs:
targetType: 'inline'
script: |
# Has to happen in this task for it to take effect
# Load the psd1 file so you can read the required modules and import them
$manifest = Import-PowerShellDataFile .\dist\*.psd1
# Import each module
$manifest.RequiredModules | ForEach-Object { Import-Module -Name $_ }
$count = 0
$r = Invoke-ScriptAnalyzer –Path ./dist –Recurse | Where-Object severity -ne "Information"
$r | ForEach-Object {Write-Host "##vso[task.logissue type=error;sourcepath=$($_.ScriptPath);linenumber=$($_.Line);columnnumber=$($_.Column);]$($_.Message)"; $count++}
if($count -ne 0) {
Write-Host "##vso[task.complete result=Failed;]Static Code Analysis with error count = $count"
}
- task: CredScan@2
displayName: 'Run CredScan'
inputs:
toolMajorVersion: 'V2'
suppressionsFile: '$(Build.SourcesDirectory)/build/credscan-supression.json'
- task: SdtReport@1
displayName: 'Create Security Analysis Report'
inputs:
AllTools: false
CredScan: true
- task: PublishSecurityAnalysisLogs@2
displayName: 'Publish Security Analysis Logs'
- task: PostAnalysis@1
displayName: 'Post Analysis'
inputs:
AllTools: false
CredScan: true
- task: CopyFiles@2
displayName: 'Copy Module to Artifacts Folder'
inputs:
Contents: |
README.md
.gitignore
dist\**
TargetFolder: '$(build.artifactstagingdirectory)/vsteam-plus'
flattenFolders: false
condition: and(succeeded(), eq(variables['System.PullRequest.IsFork'], false))
- task: PublishPipelineArtifact@1
displayName: 'Publish Module'
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)/vsteam-plus'
artifact: 'module'
condition: and(succeeded(), eq(variables['System.PullRequest.IsFork'], false))
- task: CopyFiles@2
displayName: 'Copy Integration Tests Artifacts Folder'
inputs:
Contents: |
dist\*.psd1
integration\**
TargetFolder: '$(build.artifactstagingdirectory)/Tests'
condition: and(succeeded(), eq(variables['System.PullRequest.IsFork'], false))
- task: PublishPipelineArtifact@1
displayName: 'Publish Tests'
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)/Tests'
artifact: 'test'
condition: and(succeeded(), eq(variables['System.PullRequest.IsFork'], false))
- stage: Package
displayName: Package Management
dependsOn: Build
condition: and(succeeded(), eq(variables['System.PullRequest.IsFork'], false))
jobs:
- deployment: Deploy
displayName: Package Management
pool:
vmImage: 'ubuntu-16.04'
environment: 'Default'
strategy:
runOnce:
deploy:
steps:
- task: NuGetToolInstaller@0
displayName: 'Install NuGet 5.2.0'
inputs:
versionSpec: 5.2.0
- task: PowerShell@2
displayName: 'Install Module Dependencies'
inputs:
targetType: 'inline'
script: |
# Load the psd1 file so you can read the required modules and install them
$manifest = Import-PowerShellDataFile .\$(Folder)\*.psd1
# Install each module
$manifest.RequiredModules | ForEach-Object { Install-Module -Name $_ -Repository PSGallery -Force -Scope CurrentUser -Verbose }
workingDirectory: '$(Pipeline.Workspace)/Module'
- task: PowerShell@2
displayName: 'Compute Version Number'
inputs:
targetType: 'inline'
script: |
# Load the psd1 file so you can read the version
$manifest = Import-PowerShellDataFile .\$(Folder)\*.psd1
Write-Host "Package Version Number: $($manifest.ModuleVersion).$(Build.BuildId)"
Write-Host "##vso[task.setvariable variable=PACKAGE_VERSION;isOutput=false]$($manifest.ModuleVersion).$(Build.BuildId)"
workingDirectory: '$(Pipeline.Workspace)/Module'
- task: PowerShell@2
displayName: 'Create NuSpec from PSD1'
inputs:
targetType: 'inline'
script: |
Install-Module -Name Trackyon.Nuget -Scope CurrentUser -Force -Verbose
Write-Host "Convert psd1 into a NuSpec"
ConvertTo-NuSpec -Path ./$(Folder)/vsteam-plus.psd1 -Verbose
workingDirectory: '$(Pipeline.Workspace)/Module'
- task: NuGetCommand@2
displayName: 'Pack Module'
inputs:
command: pack
packagesToPack: '$(Pipeline.Workspace)/Module/$(Folder)/vsteam-plus.nuspec'
packDestination: '$(Pipeline.Workspace)/Module/$(Folder)'
versioningScheme: byEnvVar
versionEnvVar: 'PACKAGE_VERSION'
- task: NuGetCommand@2
displayName: 'Push Module'
inputs:
command: push
packagesToPush: '$(Pipeline.Workspace)/Module/$(Folder)/*.nupkg'
publishVstsFeed: 'vsteam'
allowPackageConflicts: true
- stage: Testing
displayName: Testing stage
dependsOn: Package
jobs:
- template: build/integrationTests.yml
parameters:
displayName: 'Linux TFS 2018'
os: 'Linux'
pool: 'ubuntu-16.04'
start2018: 'true'
stop2018: 'true'
name: 'LinuxTFS2018'
apiVersion: 'TFS2018'
account: 'http://winbldbox3.centralus.cloudapp.azure.com:8080/tfs/defaultcollection'
- template: build/integrationTests.yml
parameters:
displayName: 'Windows AzD'
os: 'Windows'
pool: 'windows-latest'
name: 'windowsAzD'
apiVersion: 'VSTS'
account: 'tooltester'
- template: build/integrationTests.yml
parameters:
displayName: 'macOS TFS 2017'
os: 'macOS'
pool: 'macOS-latest'
start2017: 'true'
stop2017: 'true'
name: 'macOSTFS2017'
apiVersion: 'TFS2017'
account: 'http://sonarqube.eastus2.cloudapp.azure.com:8080/tfs/vsteam'
- stage: Production
displayName: PowerShell Gallery / GitHub Release
dependsOn: Testing
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
jobs:
- deployment: Deploy
displayName: PowerShell Gallery / GitHub Release
pool:
vmImage: 'windows-latest'
environment: 'PowerShell Gallery'
strategy:
runOnce:
deploy:
steps:
- task: NuGetToolInstaller@0
displayName: 'Install NuGet 5.2.0'
inputs:
versionSpec: 5.2.0
- task: PowerShell@2
displayName: 'Install Module Dependencies'
inputs:
targetType: 'inline'
script: |
# Load the psd1 file so you can read the required modules and install them
$manifest = Import-PowerShellDataFile .\$(Folder)\*.psd1
# Install each module
$manifest.RequiredModules | ForEach-Object { Install-Module -Name $_ -Repository PSGallery -F -Scope CurrentUser }
workingDirectory: '$(Pipeline.Workspace)/Module'
- task: PowerShell@2
displayName: 'Create NuSpec from PSD1'
inputs:
targetType: 'inline'
script: |
Install-Module -Name Trackyon.Nuget -Scope CurrentUser -Force -Verbose
ConvertTo-NuSpec -Path ./$(Folder)/vsteam-plus.psd1
# Load the psd1 file so you can read the version
$manifest = Import-PowerShellDataFile ./$(Folder)/vsteam-plus.psd1
Write-Host "##vso[task.setvariable variable=PACKAGE_VERSION;isOutput=false]$($manifest.ModuleVersion)"
workingDirectory: '$(Pipeline.Workspace)/Module'
- task: NuGetCommand@2
displayName: 'Pack Module'
inputs:
command: pack
packagesToPack: '$(Pipeline.Workspace)/Module/$(Folder)/vsteam-plus.nuspec'
packDestination: '$(Pipeline.Workspace)/Module/$(Folder)'
- task: PublishPipelineArtifact@1
displayName: 'Publish nupkg Artifact'
inputs:
targetPath: '$(Pipeline.Workspace)/Module/$(Folder)'
artifact: 'Package'
publishLocation: 'pipeline'
- task: NuGetCommand@2
displayName: 'Push Module'
inputs:
command: push
packagesToPush: '$(Pipeline.Workspace)/Module/$(Folder)/*.nupkg'
nuGetFeedType: external
publishFeedCredentials: 'PowerShell Gallery'
- task: GithubRelease@0
displayName: 'Create GitHub Release'
inputs:
gitHubConnection: Darquewarrior
repositoryName: MethodsAndPractices/vsteam-plus
tagSource: manual
tag: v$(PACKAGE_VERSION)
addChangeLog: true
compareWith: 'lastFullRelease'
assets: |
$(Pipeline.Workspace)/Module/$(Folder)/*.nupkg