execute-sdl.yml 6.7 KB
Newer Older
1
parameters:
2
  enable: 'false'                                             # Whether the SDL validation job should execute or not
3 4
  overrideParameters: ''                                       # Optional: to override values for parameters.
  additionalParameters: ''                                     # Optional: parameters that need user specific values eg: '-SourceToolsList @("abc","def") -ArtifactToolsList @("ghi","jkl")'
5 6 7 8 9 10 11 12 13
  # Optional: if specified, restore and use this version of Guardian instead of the default.
  overrideGuardianVersion: ''
  # Optional: if true, publish the '.gdn' folder as a pipeline artifact. This can help with in-depth
  # diagnosis of problems with specific tool configurations.
  publishGuardianDirectoryToPipeline: false
  # The script to run to execute all SDL tools. Use this if you want to use a script to define SDL
  # parameters rather than relying on YAML. It may be better to use a local script, because you can
  # reproduce results locally without piecing together a command based on the YAML.
  executeAllSdlToolsScript: 'eng/common/sdl/execute-all-sdl-tools.ps1'
14 15 16 17
  # There is some sort of bug (has been reported) in Azure DevOps where if this parameter is named
  # 'continueOnError', the parameter value is not correctly picked up.
  # This can also be remedied by the caller (post-build.yml) if it does not use a nested parameter
  sdlContinueOnError: false                                    # optional: determines whether to continue the build if the step errors;
18 19 20 21 22
  # optional: determines if build artifacts should be downloaded.
  downloadArtifacts: true
  # optional: determines if this job should search the directory of downloaded artifacts for
  # 'tar.gz' and 'zip' archive files and extract them before running SDL validation tasks.
  extractArchiveArtifacts: false
23
  dependsOn: ''                                                # Optional: dependencies of the job
24 25 26 27 28
  artifactNames: ''                                            # Optional: patterns supplied to DownloadBuildArtifacts
                                                               # Usage:
                                                               #  artifactNames:
                                                               #    - 'BlobArtifacts'
                                                               #    - 'Artifacts_Windows_NT_Release'
29 30 31
  # Optional: download a list of pipeline artifacts. 'downloadArtifacts' controls build artifacts,
  # not pipeline artifacts, so doesn't affect the use of this parameter.
  pipelineArtifactNames: []
32 33 34 35 36

jobs:
- job: Run_SDL
  dependsOn: ${{ parameters.dependsOn }}
  displayName: Run SDL tool
37
  condition: eq( ${{ parameters.enable }}, 'true')
38 39
  variables:
    - group: DotNet-VSTS-Bot
40
    - name: AzDOProjectName
41
      value: ${{ parameters.AzDOProjectName }}
42
    - name: AzDOPipelineId
43
      value: ${{ parameters.AzDOPipelineId }}
44
    - name: AzDOBuildId
45
      value: ${{ parameters.AzDOBuildId }}
46
    - template: /eng/common/templates/variables/sdl-variables.yml
47 48
    - name: GuardianVersion
      value: ${{ coalesce(parameters.overrideGuardianVersion, '$(DefaultGuardianVersion)') }}
49
  pool:
50 51 52 53 54 55 56
    # We don't use the collection uri here because it might vary (.visualstudio.com vs. dev.azure.com)
    ${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
      name: VSEngSS-MicroBuild2022-1ES
      demands: Cmd
    # If it's not devdiv, it's dnceng
    ${{ if ne(variables['System.TeamProject'], 'DevDiv') }}:
      name: NetCore1ESPool-Internal
57
      demands: ImageOverride -equals windows.vs2019.amd64
58 59 60
  steps:
  - checkout: self
    clean: true
61

62 63
  - template: /eng/common/templates/post-build/setup-maestro-vars.yml

64 65 66 67 68 69 70 71 72 73 74 75 76
  - ${{ if ne(parameters.downloadArtifacts, 'false')}}:
    - ${{ if ne(parameters.artifactNames, '') }}:
      - ${{ each artifactName in parameters.artifactNames }}:
        - task: DownloadBuildArtifacts@0
          displayName: Download Build Artifacts
          inputs:
            buildType: specific
            buildVersionToDownload: specific
            project: $(AzDOProjectName)
            pipeline: $(AzDOPipelineId)
            buildId: $(AzDOBuildId)
            artifactName: ${{ artifactName }}
            downloadPath: $(Build.ArtifactStagingDirectory)\artifacts
77
            checkDownloadedFiles: true
78
    - ${{ if eq(parameters.artifactNames, '') }}:
79 80 81
      - task: DownloadBuildArtifacts@0
        displayName: Download Build Artifacts
        inputs:
82 83 84 85 86
          buildType: specific
          buildVersionToDownload: specific
          project: $(AzDOProjectName)
          pipeline: $(AzDOPipelineId)
          buildId: $(AzDOBuildId)
87 88
          downloadType: specific files
          itemPattern: "**"
89
          downloadPath: $(Build.ArtifactStagingDirectory)\artifacts
90
          checkDownloadedFiles: true
91 92 93 94 95 96 97 98 99 100 101 102 103 104

  - ${{ each artifactName in parameters.pipelineArtifactNames }}:
    - task: DownloadPipelineArtifact@2
      displayName: Download Pipeline Artifacts
      inputs:
        buildType: specific
        buildVersionToDownload: specific
        project: $(AzDOProjectName)
        pipeline: $(AzDOPipelineId)
        buildId: $(AzDOBuildId)
        artifactName: ${{ artifactName }}
        downloadPath: $(Build.ArtifactStagingDirectory)\artifacts
        checkDownloadedFiles: true

105
  - powershell: eng/common/sdl/extract-artifact-packages.ps1
106 107
      -InputPath $(Build.ArtifactStagingDirectory)\artifacts\BlobArtifacts
      -ExtractPath $(Build.ArtifactStagingDirectory)\artifacts\BlobArtifacts
108
    displayName: Extract Blob Artifacts
109
    continueOnError: ${{ parameters.sdlContinueOnError }}
110

111
  - powershell: eng/common/sdl/extract-artifact-packages.ps1
112 113
      -InputPath $(Build.ArtifactStagingDirectory)\artifacts\PackageArtifacts
      -ExtractPath $(Build.ArtifactStagingDirectory)\artifacts\PackageArtifacts
114
    displayName: Extract Package Artifacts
115
    continueOnError: ${{ parameters.sdlContinueOnError }}
116 117 118 119 120 121 122 123

  - ${{ if ne(parameters.extractArchiveArtifacts, 'false') }}:
    - powershell: eng/common/sdl/extract-artifact-archives.ps1
        -InputPath $(Build.ArtifactStagingDirectory)\artifacts
        -ExtractPath $(Build.ArtifactStagingDirectory)\artifacts
      displayName: Extract Archive Artifacts
      continueOnError: ${{ parameters.sdlContinueOnError }}
  
124 125 126 127 128 129 130 131
  - template: /eng/common/templates/steps/execute-sdl.yml
    parameters:
      overrideGuardianVersion: ${{ parameters.overrideGuardianVersion }}
      executeAllSdlToolsScript: ${{ parameters.executeAllSdlToolsScript }}
      overrideParameters: ${{ parameters.overrideParameters }}
      additionalParameters: ${{ parameters.additionalParameters }}
      publishGuardianDirectoryToPipeline: ${{ parameters.publishGuardianDirectoryToPipeline }}
      sdlContinueOnError: ${{ parameters.sdlContinueOnError }}