9
9
- master
10
10
- release*
11
11
variables :
12
- - name : DOTNET_CLI_TELEMETRY_OPTOUT
13
- value : 1
14
- - name : POWERSHELL_TELEMETRY_OPTOUT
15
- value : 1
16
- - name : WindowsContainerImage
17
- value : onebranch.azurecr.io/windows/ltsc2019 /vse2022:latest
12
+ - name : DOTNET_CLI_TELEMETRY_OPTOUT
13
+ value : 1
14
+ - name : POWERSHELL_TELEMETRY_OPTOUT
15
+ value : 1
16
+ - name : WindowsContainerImage
17
+ value : onebranch.azurecr.io/windows/ltsc2022 /vse2022:latest
18
18
resources :
19
19
repositories :
20
- - repository : ComplianceRepo
21
- type : github
22
- endpoint : ComplianceGHRepo
23
- name : PowerShell/compliance
24
- ref : master
25
20
- repository : onebranchTemplates
26
21
type : git
27
22
name : OneBranch.Pipelines/GovernedTemplates
28
23
ref : refs/heads/main
29
24
extends :
30
25
template : v2/OneBranch.Official.CrossPlat.yml@onebranchTemplates
31
26
parameters :
27
+ featureFlags :
28
+ WindowsHostVersion : ' 1ESWindows2022'
32
29
customTags : ' ES365AIMigrationTooling'
33
30
globalSdl :
31
+ disableLegacyManifest : true
34
32
sbom :
35
- enabled : false
33
+ enabled : true
34
+ packageName : Microsoft.PowerShell.ScriptAnalyzer
36
35
codeql :
37
36
compiled :
38
37
enabled : true
@@ -48,113 +47,172 @@ extends:
48
47
enabled : false
49
48
50
49
stages :
51
- - stage : Build
52
- displayName : Build
50
+ - stage : stagebuild
51
+ displayName : Build and Package Microsoft.PowerShell.ScriptAnalyzer
53
52
jobs :
54
- - job : Build_Job
55
- displayName : Build Microsoft.PowerShell.ScriptAnalyzer
53
+ - job : jobbuild
54
+ displayName : Build Microsoft.PowerShell.ScriptAnalyzer Files
56
55
variables :
57
- - group : ESRP
58
56
- name : ob_outputDirectory
59
57
value : ' $(Build.ArtifactStagingDirectory)/ONEBRANCH_ARTIFACT'
60
58
- name : repoRoot
61
59
value : $(Build.SourcesDirectory)\OSS_Microsoft_PSSA
62
60
- name : ob_sdl_tsa_configFile
63
61
value : $(Build.SourcesDirectory)\OSS_Microsoft_PSSA\.config\tsaoptions.json
62
+ - name : signSrcPath
63
+ value : $(repoRoot)/out
64
+ - name : ob_sdl_sbom_enabled
65
+ value : true
66
+ - name : ob_signing_setup_enabled
67
+ value : true
68
+ # CodeQL tasks added manually to workaround signing failures
69
+ - name : ob_sdl_codeql_compiled_enabled
70
+ value : false
71
+
64
72
pool :
65
73
type : windows
66
74
steps :
67
75
- checkout : self
68
- - checkout : ComplianceRepo
76
+ env :
77
+ ob_restore_phase : true # Set ob_restore_phase to run this step before '🔒 Setup Signing' step.
69
78
70
79
- pwsh : |
71
80
if (-not (Test-Path $(repoRoot)/.config/tsaoptions.json)) {
72
81
Get-ChildItem $(Build.SourcesDirectory) -recurse -ErrorAction SilentlyContinue
73
- throw "tsaoptions.json does not exist under $(Build.SourcesDirectory)/OSS_Microsoft_PSSA /.config"
82
+ throw "tsaoptions.json does not exist under $(repoRoot) /.config"
74
83
}
75
84
displayName: Test if tsaoptions.json exists
85
+ env:
86
+ ob_restore_phase: true # Set ob_restore_phase to run this step before '🔒 Setup Signing' step.
87
+
88
+ - task : UseDotNet@2
89
+ displayName : ' Install .NET dependencies'
90
+ env :
91
+ ob_restore_phase : true # Set ob_restore_phase to run this step before '🔒 Setup Signing' step.
92
+ inputs :
93
+ packageType : ' sdk'
94
+ useGlobalJson : true
95
+ # this is to ensure that we are installing the dotnet at the same location as container by default install the dotnet sdks
96
+ installationPath : ' C:\Program Files\dotnet\'
97
+ workingDirectory : $(repoRoot)
76
98
77
- # - pwsh: |
78
- # New-Item -ItemType Directory -Path $(Build.SourcesDirectory)/.config -Force -Verbose
79
- # Copy-Item '$(Build.SourcesDirectory)/OSS_Microsoft_PSSA/.config/tsaoptions.json' '$(Build.SourcesDirectory)/.config/tsaoptions.json' -Force -Verbose
80
- # displayName: Copy tsaoptions
99
+ - task : CodeQL3000Init@0 # Add CodeQL Init task right before your 'Build' step.
100
+ env :
101
+ ob_restore_phase : true # Set ob_restore_phase to run this step before '🔒 Setup Signing' step.
102
+ inputs :
103
+ Enabled : true
104
+ AnalyzeInPipeline : true
105
+ Language : csharp
81
106
107
+ # this is installing .NET
82
108
- pwsh : |
83
- Set-Location "$(Build.SourcesDirectory)/OSS_Microsoft_PSSA "
109
+ Set-Location "$(repoRoot) "
84
110
try { ./build.ps1 -Configuration Release -All } catch { throw $_ }
85
111
displayName: Execute build
112
+ env:
113
+ ob_restore_phase: true # Set ob_restore_phase to run this step before '🔒 Setup Signing' step.
114
+
115
+ - task : CodeQL3000Finalize@0 # Add CodeQL Finalize task right after your 'Build' step.
116
+ condition : always()
117
+ env :
118
+ ob_restore_phase : true # Set ob_restore_phase to run this step before '🔒 Setup Signing' step.
119
+
120
+ - task : onebranch.pipeline.signing@1
121
+ displayName : Sign 1st party files
122
+ inputs :
123
+ command : ' sign'
124
+ signing_profile : external_distribution
125
+ files_to_sign : ' **\*.psd1;**\*.psm1;**\*.ps1xml;**\Microsoft*.dll'
126
+ search_root : $(signSrcPath)
127
+
128
+ - task : onebranch.pipeline.signing@1
129
+ displayName : Sign 3rd Party files
130
+ inputs :
131
+ command : ' sign'
132
+ signing_profile : 135020002
133
+ files_to_sign : ' **/Pluralize*.dll;**/Newtonsoft*.dll'
134
+ search_root : $(signSrcPath)
135
+
136
+ - task : CopyFiles@2
137
+ displayName : " Copy signed files to ob_outputDirectory - '$(ob_outputDirectory)'"
138
+ inputs :
139
+ SourceFolder : " $(signSrcPath)"
140
+ Contents : ' **'
141
+ TargetFolder : $(ob_outputDirectory)
86
142
87
143
- pwsh : |
88
- $signSrcPath = "$(Build.SourcesDirectory)/OSS_Microsoft_PSSA/out"
89
- # Set signing src path variable
90
- $vstsCommandString = "vso[task.setvariable variable=signSrcPath]${signSrcPath}"
91
- Write-Host "sending $vstsCommandString"
92
- Write-Host "##$vstsCommandString"
93
- $signOutStep1 = "$(Build.SourcesDirectory)/OSS_Microsoft_PSSA/Step1"
94
- $null = New-Item -ItemType Directory -Path $signOutStep1
95
- # Set signing out path variable
96
- $vstsCommandString = "vso[task.setvariable variable=signOutStep1]${signOutStep1}"
97
- Write-Host "sending $vstsCommandString"
98
- Write-Host "##$vstsCommandString"
99
- $signOutPath = "$(Build.SourcesDirectory)/OSS_Microsoft_PSSA/signed"
100
- $null = New-Item -ItemType Directory -Path $signOutPath
101
- # Set signing out path variable
102
- $vstsCommandString = "vso[task.setvariable variable=signOutPath]${signOutPath}"
103
- Write-Host "sending $vstsCommandString"
104
- Write-Host "##$vstsCommandString"
105
- # Set path variable for guardian codesign validation
106
- $vstsCommandString = "vso[task.setvariable variable=GDN_CODESIGN_TARGETDIRECTORY]${signOutPath}"
107
- Write-Host "sending $vstsCommandString"
108
- Write-Host "##$vstsCommandString"
109
- # Get version and create a variable
110
- $moduleData = Import-PowerShellDataFile "$(Build.SourcesDirectory)/OSS_Microsoft_PSSA/Engine/PSScriptAnalyzer.psd1"
144
+ $moduleData = Import-PowerShellDataFile "$(repoRoot)/Engine/PSScriptAnalyzer.psd1"
111
145
$moduleVersion = $moduleData.ModuleVersion
112
- $vstsCommandString = "vso[task.setvariable variable=moduleVersion]${moduleVersion}"
146
+ $vstsCommandString = "vso[task.setvariable variable=ob_sdl_sbom_packageversion]${moduleVersion}"
147
+
113
148
Write-Host "sending $vstsCommandString"
114
149
Write-Host "##$vstsCommandString"
115
- displayName: Setup variables for signing
116
-
117
- - template : EsrpSign.yml@ComplianceRepo
118
- parameters :
119
- buildOutputPath : $(signSrcPath)
120
- signOutputPath : $(signOutStep1)
121
- certificateId : " CP-230012"
122
- useMinimatch : true
123
- pattern : |
124
- **\*.psd1
125
- **\*.psm1
126
- **\*.ps1xml
127
- **\Microsoft*.dll
128
-
129
- - template : EsrpSign.yml@ComplianceRepo
130
- parameters :
131
- buildOutputPath : $(signOutStep1)
132
- signOutputPath : $(signOutPath)
133
- certificateId : " CP-231522"
134
- useMinimatch : true
135
- pattern : |
136
- **/Pluralize*.dll
137
- **/Newtonsoft*.dll
138
-
139
- - template : Sbom.yml@ComplianceRepo
140
- parameters :
141
- BuildDropPath : $(signOutPath)
142
- Build_Repository_Uri : ' https://github.com/powershell/PSScriptAnalyzer'
150
+ displayName: Setup SBOM Package Version
151
+
152
+ - job : nupkg
153
+ dependsOn : jobbuild
154
+ displayName : Package Microsoft.PowerShell.ScriptAnalyzer
155
+ variables :
156
+ - name : ob_outputDirectory
157
+ value : ' $(Build.ArtifactStagingDirectory)/ONEBRANCH_ARTIFACT'
158
+ - name : repoRoot
159
+ value : $(Build.SourcesDirectory)\OSS_Microsoft_PSSA
160
+ - name : ob_sdl_tsa_configFile
161
+ value : $(Build.SourcesDirectory)\OSS_Microsoft_PSSA\.config\tsaoptions.json
162
+ # Disable because SBOM was already built in the previous job
163
+ - name : ob_sdl_sbom_enabled
164
+ value : false
165
+ - name : signOutPath
166
+ value : $(repoRoot)/signed
167
+ - name : ob_signing_setup_enabled
168
+ value : true
169
+ # This job is not compiling code, so disable codeQL
170
+ - name : ob_sdl_codeql_compiled_enabled
171
+ value : false
172
+
173
+ pool :
174
+ type : windows
175
+ steps :
176
+ - checkout : self
177
+
178
+ - pwsh : |
179
+ if (-not (Test-Path $(repoRoot)/.config/tsaoptions.json)) {
180
+ Get-ChildItem $(Build.SourcesDirectory) -recurse -ErrorAction SilentlyContinue
181
+ throw "tsaoptions.json does not exist under $(repoRoot)/.config"
182
+ }
183
+ displayName: Test if tsaoptions.json exists
184
+
185
+ - task : DownloadPipelineArtifact@2
186
+ displayName : ' Download build files'
187
+ inputs :
188
+ targetPath : $(signOutPath)
189
+ artifact : drop_stagebuild_jobbuild
143
190
144
191
- pwsh : |
145
- Set-Location "$(Build.SourcesDirectory)/OSS_Microsoft_PSSA"
192
+ Set-Location "$(signOutPath)"
193
+ dir -dir -recurse *
194
+ displayName: Capture artifacts structure
195
+
196
+ - pwsh : |
197
+ Set-Location "$(repoRoot)"
146
198
./build -BuildNupkg -CopyManifest -signed
147
199
displayName: Create nupkg for publishing
148
200
149
- - task : CopyFiles@2
150
- displayName : " Copy Files for 'publish build directory' publish task "
201
+ - task : onebranch.pipeline.signing@1
202
+ displayName : Sign nupkg
151
203
inputs :
152
- SourceFolder : " $(Build.SourcesDirectory)/OSS_Microsoft_PSSA"
153
- Contents : ' **'
154
- TargetFolder : $(Build.ArtifactStagingDirectory)/ONEBRANCH_ARTIFACT/build
204
+ command : ' sign'
205
+ signing_profile : external_distribution
206
+ files_to_sign : ' **\*.nupkg'
207
+ search_root : $(signOutPath)
208
+
209
+ - pwsh : |
210
+ Set-Location "$(repoRoot)"
211
+ dir -file -recurse *.nupkg
212
+ displayName: Find Nupkg
155
213
156
214
- task : CopyFiles@2
157
- displayName : " Copy Files for 'Publish module nupkg' publish task "
215
+ displayName : " Copy nupkg to ob_outputDirectory - '$(ob_outputDirectory)' "
158
216
inputs :
159
- Contents : " $(signOutPath)/ PSScriptAnalyzer.$(moduleVersion) .nupkg"
160
- TargetFolder : $(Build.ArtifactStagingDirectory)/ONEBRANCH_ARTIFACT/nupkg
217
+ Contents : " $(repoRoot)/**/ PSScriptAnalyzer.* .nupkg"
218
+ TargetFolder : $(ob_outputDirectory)
0 commit comments