summaryrefslogtreecommitdiff
path: root/eng/common/templates/job/publish-build-assets.yml
blob: 9e77ef1b54b89738ed9d62e5341cbc5cf4988c66 (plain)
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
46
47
48
49
50
51
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
parameters:
  configuration: 'Debug'

  # Optional: condition for the job to run
  condition: ''

  # Optional: 'true' if future jobs should run even if this job fails
  continueOnError: false

  # Optional: dependencies of the job
  dependsOn: ''

  # Optional: Include PublishBuildArtifacts task
  enablePublishBuildArtifacts: false

  # Optional: A defined YAML pool - https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=vsts&tabs=schema#pool
  pool: {}

  # 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

  # Optional: whether the build's artifacts will be published using release pipelines or direct feed publishing
  publishUsingPipelines: false

jobs:
- job: Asset_Registry_Publish

  dependsOn: ${{ parameters.dependsOn }}

  displayName: Publish to Build Asset Registry

  pool: ${{ parameters.pool }}

  variables:
  - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
    - name: _BuildConfig
      value: ${{ parameters.configuration }}
    - group: Publish-Build-Assets

  steps:
  - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
    - task: DownloadBuildArtifacts@0
      displayName: Download artifact
      inputs:
        artifactName: AssetManifests
        downloadPath: '$(Build.StagingDirectory)/Download'
      condition: ${{ parameters.condition }}
      continueOnError: ${{ parameters.continueOnError }}
    - task: PowerShell@2
      displayName: Publish Build Assets
      inputs:
        filePath: eng\common\sdk-task.ps1
        arguments: -task PublishBuildAssets -restore -msbuildEngine dotnet
          /p:ManifestsPath='$(Build.StagingDirectory)/Download/AssetManifests'
          /p:BuildAssetRegistryToken=$(MaestroAccessToken)
          /p:MaestroApiEndpoint=https://maestro-prod.westus2.cloudapp.azure.com
          /p:PublishUsingPipelines=${{ parameters.publishUsingPipelines }}
          /p:Configuration=$(_BuildConfig)
      condition: ${{ parameters.condition }}
      continueOnError: ${{ parameters.continueOnError }}
    - task: powershell@2
      displayName: Create ReleaseConfigs Artifact
      inputs:
        targetType: inline
        script: |
          Add-Content -Path "$(Build.StagingDirectory)/ReleaseConfigs.txt" -Value $(BARBuildId)
          Add-Content -Path "$(Build.StagingDirectory)/ReleaseConfigs.txt" -Value "$(DefaultChannels)"
          Add-Content -Path "$(Build.StagingDirectory)/ReleaseConfigs.txt" -Value $(IsStableBuild)
    - task: PublishBuildArtifacts@1
      displayName: Publish ReleaseConfigs Artifact
      inputs:
        PathtoPublish: '$(Build.StagingDirectory)/ReleaseConfigs.txt'
        PublishLocation: Container
        ArtifactName: ReleaseConfigs
    - ${{ if eq(parameters.enablePublishBuildArtifacts, 'true') }}:
      - task: PublishBuildArtifacts@1
        displayName: Publish Logs to VSTS
        inputs:
          PathtoPublish: '$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)'
          PublishLocation: Container
          ArtifactName: $(Agent.Os)_PublishBuildAssets
        continueOnError: true
        condition: always()