Skip to content

Commit 921d2c6

Browse files
authored
Stop remaining auto-injected component detection runs (#23755)
- was still running in every job where explicit CD build step did not execute - caused consistent errors in Linux MUSL x64 (Alpine) jobs - error was ignored but made build failure diagnosis more difficult - totally redundant in test jobs
1 parent 93634cd commit 921d2c6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

.azure/pipelines/jobs/default-build.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ jobs:
242242
continueOnError: true
243243
condition: always()
244244

245+
# Run component detection after all successful Build:* jobs unless overridden e.g. for Alpine build.
245246
- ${{ if and(startsWith(parameters.jobDisplayName, 'Build:'), ne(variables['skipComponentGovernanceDetection'], 'true'), ne(parameters.skipComponentGovernanceDetection, 'true'), notin(variables['Build.Reason'], 'PullRequest')) }}:
246247
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
247248
condition: and(succeeded(), ne(variables['CG_RAN'], 'true'))
@@ -253,6 +254,11 @@ jobs:
253254
ignoreDirectories: '.dotnet,.packages,artifacts/log,artifacts/symbols,artifacts/tmp'
254255
sourceScanPath: $(Build.SourcesDirectory)
255256
verbosity: Verbose
257+
# Make sure auto-injected component detection does _not_ execute in other jobs nor when overridden.
258+
# No need to recheck variables or build reason because auto-injected component detection honors those values.
259+
- ${{ if or(not(startsWith(parameters.jobDisplayName, 'Build:')), eq(parameters.skipComponentGovernanceDetection, 'true')) }}:
260+
- script: echo "##vso[task.setvariable variable=CG_RAN]true"
261+
displayName: 'Skip Component Detection'
256262

257263
- ${{ each artifact in parameters.artifacts }}:
258264
- task: PublishBuildArtifacts@1

0 commit comments

Comments
 (0)