1
+ # The name of the build that will be seen in mscodehub
1
2
name : PSSA-Release-$(Build.BuildId)
3
+ # how is the build triggered
4
+ # since this is a release build, no trigger as it's a manual release
2
5
trigger : none
3
6
4
7
pr :
7
10
- master
8
11
- release*
9
12
13
+ # variables to set in the build environment
10
14
variables :
11
15
DOTNET_CLI_TELEMETRY_OPTOUT : 1
12
16
POWERSHELL_TELEMETRY_OPTOUT : 1
13
17
18
+ # since this build relies on templates, we need access to those
19
+ # This needs a service connection in the build to work
20
+ # the *name* of the service connection must be the same as the endpoint
14
21
resources :
15
22
repositories :
16
23
- repository : ComplianceRepo
17
24
type : github
18
25
endpoint : ComplianceGHRepo
19
26
name : PowerShell/compliance
27
+ # this can be any branch of your choosing
20
28
ref : master
21
29
30
+ # the stages in this build. There are 2
31
+ # the assumption for script analyzer is that test is done as part of
32
+ # CI so we needn't do it here
22
33
stages :
23
34
- stage : Build
24
35
displayName : Build
@@ -27,16 +38,21 @@ stages:
27
38
jobs :
28
39
- job : Build_Job
29
40
displayName : Build Microsoft.PowerShell.ScriptAnalyzer
41
+ # note the variable reference to ESRP.
42
+ # this must be created in Project -> Pipelines -> Library -> VariableGroups
43
+ # where it describes the link to the SigningServer
30
44
variables :
31
45
- group : ESRP
32
46
steps :
33
47
- checkout : self
34
48
49
+ # the steps for building the module go here
35
50
- pwsh : |
36
51
Set-Location "$(Build.SourcesDirectory)/OSS_Microsoft_PSSA"
37
52
try { ./build.ps1 -Configuration Release -All } catch { throw $_ }
38
53
displayName: Execute build
39
54
55
+ # these are setting vso variables which will be persisted between stages
40
56
- pwsh : |
41
57
$signSrcPath = "$(Build.SourcesDirectory)/OSS_Microsoft_PSSA/out"
42
58
# Set signing src path variable
@@ -73,8 +89,15 @@ stages:
73
89
74
90
displayName: Setup variables for signing
75
91
92
+ # checkout the Compliance repository so it can be used to do the actual signing
76
93
- checkout : ComplianceRepo
77
94
95
+ # in script analyzer, we must sign with 2 different certs
96
+ # the normal cert for MS created items and the 3rd party cert
97
+ # this the MS authored step
98
+ # Because this needs 2 certs, we do it in 2 steps.
99
+ # the first step signs the binaries and puts them in a staging directory which
100
+ # will then be used for the second step.
78
101
- template : EsrpSign.yml@ComplianceRepo
79
102
parameters :
80
103
# the folder which contains the binaries to sign
@@ -92,6 +115,11 @@ stages:
92
115
**\*.ps1xml
93
116
**\Microsoft*.dll
94
117
118
+ # this is the second step of the signing.
119
+ # note that the buildOutputPath (where we get the files to sign)
120
+ # is the same as the signOutputPath in the previous step
121
+ # at the end of this step we will have all the files signed that should be
122
+ # signOutPath is the location which contains the files we will use to make the module
95
123
- template : EsrpSign.yml@ComplianceRepo
96
124
parameters :
97
125
# the folder which contains the binaries to sign
@@ -104,20 +132,26 @@ stages:
104
132
# the file pattern to use - only sign newtonsoft
105
133
pattern : ' Newtonsoft*.dll'
106
134
135
+ # now create the nupkg which we will use to publish the module
136
+ # to the powershell gallery (not part of this yaml)
107
137
- pwsh : |
108
138
Set-Location "$(Build.SourcesDirectory)/OSS_Microsoft_PSSA"
109
139
./build -BuildNupkg -signed
110
140
displayName: Create nupkg for publishing
111
141
142
+ # finally publish the parts of the build which will be used in the next stages
143
+ # if it's not published, the subsequent stages will not be able to access it.
144
+ # This is the build directory (it contains all of the dll/pdb files)
112
145
- publish : " $(Build.SourcesDirectory)/OSS_Microsoft_PSSA"
113
146
artifact : build
114
147
displayName : publish build directory
115
148
116
- # export the nupkg only
149
+ # export the nupkg only which will be used in the release pipeline
117
150
- publish : " $(signOutPath)/PSScriptAnalyzer.$(moduleVersion).nupkg"
118
151
artifact : nupkg
119
152
displayName : Publish module nupkg
120
153
154
+ # Now on to the compliance stage
121
155
- stage : compliance
122
156
displayName : Compliance
123
157
dependsOn : Build
@@ -131,24 +165,23 @@ stages:
131
165
- download : current
132
166
artifact : build
133
167
134
- - pwsh : |
135
- Get-ChildItem -Path "$(Pipeline.Workspace)\build" -Recurse
136
- Get-Location
137
- Get-ChildItem -Recurse -File -Name
138
- displayName: Capture downloaded artifacts
139
-
168
+ # use the templates in the compliance repo
169
+ # since script analyzer has modules, we're using the assembly-module-compliance template
170
+ # if you don't have assemblies, you should use script-module-compliance template
140
171
- template : assembly-module-compliance.yml@ComplianceRepo
141
172
parameters :
142
- # component-governance
173
+ # component-governance - the path to sources
143
174
sourceScanPath : ' $(Build.SourcesDirectory)/OSS_Microsoft_PSSA'
144
- # binskim
175
+ # binskim - this isn't recursive, so you need the path to the assemblies
145
176
AnalyzeTarget : ' $(Pipeline.Workspace)\build\bin\PSV7Release\netcoreapp3.1\*.dll'
146
- # credscan
177
+ # credscan - scan the repo for credentials
178
+ # you can suppress some files with this.
147
179
suppressionsFile : ' $(Build.SourcesDirectory)/OSS_Microsoft_PSSA/tools/ReleaseBuild/CredScan.Suppressions.json'
148
180
# TermCheck
149
181
optionsRulesDBPath : ' '
150
182
optionsFTPath : ' '
151
183
# tsa-upload
184
+ # the compliance scanning must be uploaded, which you need to request
152
185
codeBaseName : ' PSSA_202004'
153
186
# selections
154
187
APIScan : false # set to false when not using Windows APIs.
0 commit comments