|
| 1 | +# This file is the main entry point for the Build Promotion build definition. |
| 2 | + |
| 3 | +parameters: |
| 4 | + - name: PublishingInfraVersion |
| 5 | + displayName: Which version of publishing should be used to promote the build definition? |
| 6 | + type: number |
| 7 | + default: 3 |
| 8 | + values: |
| 9 | + - 2 |
| 10 | + - 3 |
| 11 | + |
| 12 | + - name: BARBuildId |
| 13 | + displayName: "Maestro ID of the build to be promoted:" |
| 14 | + type: number |
| 15 | + |
| 16 | + - name: PromoteToChannelIds |
| 17 | + displayName: Which Maestro channels' IDs should the build be promoted to? (comma separated) |
| 18 | + type: string |
| 19 | + default: ' ' |
| 20 | + |
| 21 | + - name: EnableSourceLinkValidation |
| 22 | + displayName: Should Sourcelink validation be performed? |
| 23 | + type: boolean |
| 24 | + default: false |
| 25 | + |
| 26 | + - name: EnableNugetValidation |
| 27 | + displayName: Should NuGet metadata validation be performed? |
| 28 | + type: boolean |
| 29 | + default: false |
| 30 | + |
| 31 | + - name: EnableSigningValidation |
| 32 | + displayName: Should signing validation be performed? |
| 33 | + type: boolean |
| 34 | + default: false |
| 35 | + |
| 36 | + - name: PublishInstallersAndChecksums |
| 37 | + displayName: Should installers and checksums be published? |
| 38 | + type: boolean |
| 39 | + default: false |
| 40 | + |
| 41 | + - name: SymbolPublishingAdditionalParameters |
| 42 | + displayName: Additional (MSBuild) properties for symbol publishing |
| 43 | + type: string |
| 44 | + default: ' ' |
| 45 | + |
| 46 | + - name: ArtifactsPublishingAdditionalParameters |
| 47 | + displayName: Additional (MSBuild) properties for general asset publishing |
| 48 | + type: string |
| 49 | + default: ' ' |
| 50 | + |
| 51 | + - name: SigningValidationAdditionalParameters |
| 52 | + displayName: Additional (MSBuild) properties for signing validation |
| 53 | + type: string |
| 54 | + default: ' ' |
| 55 | + |
| 56 | +trigger: none |
| 57 | + |
| 58 | +variables: |
| 59 | + _DotNetArtifactsCategory: .NETCore |
| 60 | + |
| 61 | +stages: |
| 62 | +- stage: prepare_promotion |
| 63 | + displayName: Prepare for Promotion |
| 64 | + jobs: |
| 65 | + - job: |
| 66 | + displayName: Validate Parameters |
| 67 | + variables: |
| 68 | + - template: common\templates\post-build\common-variables.yml |
| 69 | + steps: |
| 70 | + - checkout: none |
| 71 | + |
| 72 | + - task: PowerShell@2 |
| 73 | + displayName: Validate Build & Channel |
| 74 | + inputs: |
| 75 | + targetType: inline |
| 76 | + script: | |
| 77 | + # Keeping this script inline so that we don't need to checkout the whole repo to use just one file |
| 78 | + try { |
| 79 | + $buildApiEndpoint = "$(MaestroApiEndPoint)/api/builds/${Env:BARBuildId}?api-version=$(MaestroApiVersion)" |
| 80 | +
|
| 81 | + $apiHeaders = New-Object 'System.Collections.Generic.Dictionary[[String],[String]]' |
| 82 | + $apiHeaders.Add('Accept', 'application/json') |
| 83 | + $apiHeaders.Add('Authorization',"Bearer ${Env:MAESTRO_API_TOKEN}") |
| 84 | +
|
| 85 | + $buildInfo = try { Invoke-WebRequest -Method Get -Uri $buildApiEndpoint -Headers $apiHeaders | ConvertFrom-Json } catch { Write-Host "Error: $_" } |
| 86 | +
|
| 87 | + if (!$buildInfo) { |
| 88 | + Write-Host "Build with BAR ID ${Env:BARBuildId} was not found in BAR!" |
| 89 | + exit 1 |
| 90 | + } |
| 91 | +
|
| 92 | + $channels = ${Env:PromoteToChannelIds} -split "," |
| 93 | + foreach ($channelId in $channels) { |
| 94 | + $channelApiEndpoint = "$(MaestroApiEndPoint)/api/channels/${channelId}?api-version=$(MaestroApiVersion)" |
| 95 | + $channelInfo = try { Invoke-WebRequest -Method Get -Uri $channelApiEndpoint -Headers $apiHeaders | ConvertFrom-Json } catch { Write-Host "Error: $_" } |
| 96 | +
|
| 97 | + if (!$channelInfo) { |
| 98 | + Write-Host "Channel with ID ${channelId} was not found in BAR. Aborting." |
| 99 | + exit 1 |
| 100 | + } |
| 101 | + } |
| 102 | + |
| 103 | + $azureDevOpsBuildNumber = $buildInfo.azureDevOpsBuildNumber |
| 104 | + $channelName = $channelInfo.name |
| 105 | + $azureDevOpsRepository = "Unknown" |
| 106 | + $lastIndexOfSlash = $buildInfo.azureDevOpsRepository.LastIndexOf('/') |
| 107 | +
|
| 108 | + if ($lastIndexOfSlash -ne -1) { |
| 109 | + $azureDevOpsRepository = $buildInfo.azureDevOpsRepository.Substring($lastIndexOfSlash + 1) |
| 110 | +
|
| 111 | + # Invalid chars in Azdo build number: '"', '/', ':', '<', '>', '\', '|', '?', '@', and '*' |
| 112 | + $azureDevOpsRepository = $azureDevOpsRepository -replace '["/:<>\\|?@*"]', '_' |
| 113 | + } |
| 114 | +
|
| 115 | + $buildNumberName = "Promoting $azureDevOpsRepository build $azureDevOpsBuildNumber to channel(s) ${Env:PromoteToChannelIds}#" |
| 116 | +
|
| 117 | + # Maximum buildnumber length is 255 chars |
| 118 | + if ($buildNumberName.Length -GT 255) { |
| 119 | + $buildNumberName = $buildNumberName.Substring(0, 255) |
| 120 | + } |
| 121 | +
|
| 122 | + Write-Host "##vso[build.updatebuildnumber]$buildNumberName" |
| 123 | + Write-Host "##vso[build.addbuildtag]$channelName" |
| 124 | + } |
| 125 | + catch { |
| 126 | + Write-Host $_ |
| 127 | + Write-Host $_.Exception |
| 128 | + Write-Host $_.ScriptStackTrace |
| 129 | + exit 1 |
| 130 | + } |
| 131 | + env: |
| 132 | + MAESTRO_API_TOKEN: $(MaestroApiAccessToken) |
| 133 | + BARBuildId: ${{ parameters.BARBuildId }} |
| 134 | + PromoteToChannelIds: ${{ parameters.PromoteToChannelIds }} |
| 135 | + |
| 136 | +- ${{ if le(parameters.PublishingInfraVersion, 2) }}: |
| 137 | + - template: \eng\common\templates\post-build\post-build.yml |
| 138 | + parameters: |
| 139 | + PromoteToChannelIds: ${{ parameters.PromoteToChannelIds }} |
| 140 | + BARBuildId: ${{ parameters.BARBuildId }} |
| 141 | + |
| 142 | + enableSourceLinkValidation: ${{ parameters.EnableSourceLinkValidation }} |
| 143 | + enableNugetValidation: ${{ parameters.EnableNugetValidation }} |
| 144 | + enableSigningValidation: ${{ parameters.EnableSigningValidation }} |
| 145 | + |
| 146 | + validateDependsOn: |
| 147 | + - prepare_promotion |
| 148 | + |
| 149 | + publishInstallersAndChecksums: ${{ parameters.PublishInstallersAndChecksums }} |
| 150 | + symbolPublishingAdditionalParameters: ${{ parameters.SymbolPublishingAdditionalParameters }} |
| 151 | + artifactsPublishingAdditionalParameters: ${{ parameters.ArtifactsPublishingAdditionalParameters }} |
| 152 | + signingValidationAdditionalParameters: ${{ parameters.SigningValidationAdditionalParameters }} |
| 153 | + |
| 154 | +- ${{ if ge(parameters.PublishingInfraVersion, 3) }}: |
| 155 | + - template: \eng\publishing\v3\publish.yml |
| 156 | + parameters: |
| 157 | + PromoteToChannelIds: ${{ parameters.PromoteToChannelIds }} |
| 158 | + BARBuildId: ${{ parameters.BARBuildId }} |
| 159 | + |
| 160 | + enableSourceLinkValidation: ${{ parameters.EnableSourceLinkValidation }} |
| 161 | + enableNugetValidation: ${{ parameters.EnableNugetValidation }} |
| 162 | + enableSigningValidation: ${{ parameters.EnableSigningValidation }} |
| 163 | + |
| 164 | + validateDependsOn: |
| 165 | + - prepare_promotion |
| 166 | + |
| 167 | + publishInstallersAndChecksums: ${{ parameters.PublishInstallersAndChecksums }} |
| 168 | + symbolPublishingAdditionalParameters: ${{ parameters.SymbolPublishingAdditionalParameters }} |
| 169 | + artifactsPublishingAdditionalParameters: ${{ parameters.ArtifactsPublishingAdditionalParameters }} |
| 170 | + signingValidationAdditionalParameters: ${{ parameters.SigningValidationAdditionalParameters }} |
0 commit comments