job.yml 7.4 KB
Newer Older
T
Tomáš Matoušek 已提交
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
parameters:
# Job schema parameters - https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=vsts&tabs=schema#job
  cancelTimeoutInMinutes: ''

  condition: ''

  continueOnError: false

  container: ''

  dependsOn: ''

  displayName: ''

  steps: []

  pool: ''

  strategy: ''

  timeoutInMinutes: ''

  variables: []

  workspace: ''

# Job base template specific parameters
  # Optional: Enable installing Microbuild plugin
  #           if 'true', these "variables" must be specified in the variables object or as part of the queue matrix
  #             _TeamName - the name of your team
  #             _SignType - 'test' or 'real'
  enableMicrobuild: false

  # Optional: Include PublishBuildArtifacts task
  enablePublishBuildArtifacts: false

  # Optional: Enable publishing to the build asset registry
  enablePublishBuildAssets: false

  # Optional: Include PublishTestResults task
  enablePublishTestResults: false

  # Optional: enable sending telemetry
  enableTelemetry: false

46
  # Optional: define the helix repo for telemetry (example: 'dotnet/arcade')
T
Tomáš Matoušek 已提交
47 48
  helixRepo: ''

49 50 51
  # Optional: define the helix type for telemetry (example: 'build/product/')
  helixType: ''

T
Tomáš Matoušek 已提交
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
  # Required: name of the job
  name: ''

  # Optional: should run as a public build even in the internal project
  #           if 'true', the build won't run any of the internal only steps, even if it is running in non-public projects.
  runAsPublic: false

# Internal resources (telemetry, microbuild) can only be accessed from non-public projects,
# and some (Microbuild) should only be applied to non-PR cases for internal builds.

jobs:
- job: ${{ parameters.name }}

  ${{ if ne(parameters.cancelTimeoutInMinutes, '') }}:
    cancelTimeoutInMinutes: ${{ parameters.cancelTimeoutInMinutes }}

  ${{ if ne(parameters.condition, '') }}:
    condition: ${{ parameters.condition }}

  ${{ if ne(parameters.container, '') }}:
    container: ${{ parameters.container }}

  ${{ if ne(parameters.continueOnError, '') }}:
    continueOnError: ${{ parameters.continueOnError }}

  ${{ if ne(parameters.dependsOn, '') }}:
    dependsOn: ${{ parameters.dependsOn }}

  ${{ if ne(parameters.displayName, '') }}:
    displayName: ${{ parameters.displayName }}

  ${{ if ne(parameters.pool, '') }}:
    pool: ${{ parameters.pool }}

  ${{ if ne(parameters.strategy, '') }}:
    strategy: ${{ parameters.strategy }}

  ${{ if ne(parameters.timeoutInMinutes, '') }}:
    timeoutInMinutes: ${{ parameters.timeoutInMinutes }}

  variables:
93 94 95
  - ${{ if eq(parameters.enableTelemetry, 'true') }}:
    - name: DOTNET_CLI_TELEMETRY_PROFILE
      value: '$(Build.Repository.Uri)'
T
Tomáš Matoušek 已提交
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
  - ${{ each variable in parameters.variables }}:
    # handle name-value variable syntax
    # example:
    # - name: [key]
    #   value: [value]
    - ${{ if ne(variable.name, '') }}:
      - name: ${{ variable.name }}
        value: ${{ variable.value }}
    
    # handle variable groups
    - ${{ if ne(variable.group, '') }}:
      - group: ${{ variable.group }}

    # handle key-value variable syntax.
    # example:
    # - [key]: [value]
    - ${{ if and(eq(variable.name, ''), eq(variable.group, '')) }}:
      - ${{ each pair in variable }}:
        - name: ${{ pair.key }}
          value: ${{ pair.value }}

117 118 119
  # DotNet-HelixApi-Access provides 'HelixApiAccessToken' for internal builds
  - ${{ if and(eq(parameters.enableTelemetry, 'true'), eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
    - group: DotNet-HelixApi-Access
T
Tomáš Matoušek 已提交
120 121 122 123 124 125

  ${{ if ne(parameters.workspace, '') }}:
    workspace: ${{ parameters.workspace }}

  steps:
  - ${{ if eq(parameters.enableTelemetry, 'true') }}:
126 127 128 129 130
    # Telemetry tasks are built from https://github.com/dotnet/arcade-extensions
    - task: sendStartTelemetry@0
      displayName: 'Send Helix Start Telemetry'
      inputs:
        helixRepo: ${{ parameters.helixRepo }}
131 132
        ${{ if ne(parameters.helixType, '') }}:
          helixType: ${{ parameters.helixType }}
133
        buildConfig: $(_BuildConfig)
T
Tomáš Matoušek 已提交
134
        runAsPublic: ${{ parameters.runAsPublic }}
135 136
      continueOnError: ${{ parameters.continueOnError }}
      condition: always()
T
Tomáš Matoušek 已提交
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

  - ${{ if eq(parameters.enableMicrobuild, 'true') }}:
    - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
      - task: MicroBuildSigningPlugin@2
        displayName: Install MicroBuild plugin
        inputs:
          signType: $(_SignType)
          zipSources: false
          feedSource: https://dnceng.pkgs.visualstudio.com/_packaging/MicroBuildToolset/nuget/v3/index.json
        env:
          TeamName: $(_TeamName)
        continueOnError: ${{ parameters.continueOnError }}
        condition: and(succeeded(), in(variables['_SignType'], 'real', 'test'), eq(variables['Agent.Os'], 'Windows_NT'))

  - ${{ each step in parameters.steps }}:
    - ${{ step }}

  - ${{ if eq(parameters.enableMicrobuild, 'true') }}:
    - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
      - task: MicroBuildCleanup@1
        displayName: Execute Microbuild cleanup tasks  
        condition: and(always(), in(variables['_SignType'], 'real', 'test'), eq(variables['Agent.Os'], 'Windows_NT'))
        continueOnError: ${{ parameters.continueOnError }}
        env:
          TeamName: $(_TeamName)

  - ${{ if eq(parameters.enableTelemetry, 'true') }}:
164 165 166 167 168
    # Telemetry tasks are built from https://github.com/dotnet/arcade-extensions
    - task: sendEndTelemetry@0
      displayName: 'Send Helix End Telemetry'
      continueOnError: ${{ parameters.continueOnError }}
      condition: always()
T
Tomáš Matoušek 已提交
169 170 171

  - ${{ if eq(parameters.enablePublishBuildArtifacts, 'true') }}:
    - task: PublishBuildArtifacts@1
172
      displayName: Publish Logs
T
Tomáš Matoušek 已提交
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
      inputs:
        PathtoPublish: '$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)'
        PublishLocation: Container
        ArtifactName: $(Agent.Os)_$(Agent.JobName)
      continueOnError: true
      condition: always()

  - ${{ if eq(parameters.enablePublishTestResults, 'true') }}:
    - task: PublishTestResults@2
      displayName: Publish Test Results
      inputs:
        testResultsFormat: 'xUnit'
        testResultsFiles: '*.xml' 
        searchFolder: '$(Build.SourcesDirectory)/artifacts/TestResults/$(_BuildConfig)'
      continueOnError: true
      condition: always()
    
190
  - ${{ if and(eq(parameters.enablePublishBuildAssets, true), ne(variables['_PublishUsingPipelines'], 'true'), eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
T
Tomáš Matoušek 已提交
191 192 193 194 195 196 197 198 199 200 201 202 203 204
    - task: CopyFiles@2
      displayName: Gather Asset Manifests
      inputs:
        SourceFolder: '$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/AssetManifest'
        TargetFolder: '$(Build.StagingDirectory)/AssetManifests'
      continueOnError: ${{ parameters.continueOnError }}
      condition: and(succeeded(), eq(variables['_DotNetPublishToBlobFeed'], 'true'))
    - task: PublishBuildArtifacts@1
      displayName: Push Asset Manifests
      inputs:
        PathtoPublish: '$(Build.StagingDirectory)/AssetManifests'
        PublishLocation: Container
        ArtifactName: AssetManifests
      continueOnError: ${{ parameters.continueOnError }}
205
      condition: and(succeeded(), eq(variables['_DotNetPublishToBlobFeed'], 'true'))