|
| 1 | +param( |
| 2 | + [Parameter(Mandatory=$true)][int] $BuildId, |
| 3 | + [Parameter(Mandatory=$true)][string] $AzdoToken, |
| 4 | + [Parameter(Mandatory=$true)][string] $MaestroToken, |
| 5 | + [Parameter(Mandatory=$false)][string] $MaestroApiEndPoint = 'https://maestro-prod.westus2.cloudapp.azure.com', |
| 6 | + [Parameter(Mandatory=$true)][string] $WaitPublishingFinish, |
| 7 | + [Parameter(Mandatory=$true)][string] $EnableSourceLinkValidation, |
| 8 | + [Parameter(Mandatory=$true)][string] $EnableSigningValidation, |
| 9 | + [Parameter(Mandatory=$true)][string] $EnableNugetValidation, |
| 10 | + [Parameter(Mandatory=$true)][string] $PublishInstallersAndChecksums, |
| 11 | + [Parameter(Mandatory=$false)][string] $ArtifactsPublishingAdditionalParameters, |
| 12 | + [Parameter(Mandatory=$false)][string] $SigningValidationAdditionalParameters |
| 13 | +) |
| 14 | + |
| 15 | +try { |
| 16 | + . $PSScriptRoot\post-build-utils.ps1 |
| 17 | + . $PSScriptRoot\..\darc-init.ps1 |
| 18 | + |
| 19 | + $optionalParams = [System.Collections.ArrayList]::new() |
| 20 | + |
| 21 | + if ("" -ne $ArtifactsPublishingAdditionalParameters) { |
| 22 | + $optionalParams.Add("artifact-publishing-parameters") | Out-Null |
| 23 | + $optionalParams.Add($ArtifactsPublishingAdditionalParameters) | Out-Null |
| 24 | + } |
| 25 | + |
| 26 | + if ("false" -eq $WaitPublishingFinish) { |
| 27 | + $optionalParams.Add("--no-wait") | Out-Null |
| 28 | + } |
| 29 | + |
| 30 | + if ("true" -eq $PublishInstallersAndChecksums) { |
| 31 | + $optionalParams.Add("--publish-installers-and-checksums") | Out-Null |
| 32 | + } |
| 33 | + |
| 34 | + if ("true" -eq $EnableNugetValidation) { |
| 35 | + $optionalParams.Add("--validate-nuget") | Out-Null |
| 36 | + } |
| 37 | + |
| 38 | + if ("true" -eq $EnableSourceLinkValidation) { |
| 39 | + $optionalParams.Add("--validate-sourcelinkchecksums") | Out-Null |
| 40 | + } |
| 41 | + |
| 42 | + if ("true" -eq $EnableSigningValidation) { |
| 43 | + $optionalParams.Add("--validate-signingchecksums") | Out-Null |
| 44 | + |
| 45 | + if ("" -ne $SigningValidationAdditionalParameters) { |
| 46 | + $optionalParams.Add("--signing-validation-parameters") | Out-Null |
| 47 | + $optionalParams.Add($SigningValidationAdditionalParameters) | Out-Null |
| 48 | + } |
| 49 | + } |
| 50 | + |
| 51 | + & darc add-build-to-channel ` |
| 52 | + --id $buildId ` |
| 53 | + --default-channels ` |
| 54 | + --source-branch master ` |
| 55 | + --azdev-pat $AzdoToken ` |
| 56 | + --bar-uri $MaestroApiEndPoint ` |
| 57 | + --password $MaestroToken ` |
| 58 | + @optionalParams |
| 59 | + |
| 60 | + if ($LastExitCode -ne 0) { |
| 61 | + Write-Host "Problems using Darc to promote build ${buildId} to default channels. Stopping execution..." |
| 62 | + exit 1 |
| 63 | + } |
| 64 | + |
| 65 | + Write-Host 'done.' |
| 66 | +} |
| 67 | +catch { |
| 68 | + Write-Host $_ |
| 69 | + Write-PipelineTelemetryError -Category 'PromoteBuild' -Message "There was an error while trying to publish build '$BuildId' to default channels." |
| 70 | + ExitWithExitCode 1 |
| 71 | +} |
0 commit comments