msbuild
48 строк · 1.6 Кб
1param(
2[Parameter(Mandatory=$true)][int] $BuildId,
3[Parameter(Mandatory=$true)][int] $ChannelId,
4[Parameter(Mandatory=$true)][string] $MaestroApiAccessToken,
5[Parameter(Mandatory=$false)][string] $MaestroApiEndPoint = 'https://maestro.dot.net',
6[Parameter(Mandatory=$false)][string] $MaestroApiVersion = '2019-01-16'
7)
8
9try {
10. $PSScriptRoot\post-build-utils.ps1
11
12# Check that the channel we are going to promote the build to exist
13$channelInfo = Get-MaestroChannel -ChannelId $ChannelId
14
15if (!$channelInfo) {
16Write-PipelineTelemetryCategory -Category 'PromoteBuild' -Message "Channel with BAR ID $ChannelId was not found in BAR!"
17ExitWithExitCode 1
18}
19
20# Get info about which channel(s) the build has already been promoted to
21$buildInfo = Get-MaestroBuild -BuildId $BuildId
22
23if (!$buildInfo) {
24Write-PipelineTelemetryError -Category 'PromoteBuild' -Message "Build with BAR ID $BuildId was not found in BAR!"
25ExitWithExitCode 1
26}
27
28# Find whether the build is already assigned to the channel or not
29if ($buildInfo.channels) {
30foreach ($channel in $buildInfo.channels) {
31if ($channel.Id -eq $ChannelId) {
32Write-Host "The build with BAR ID $BuildId is already on channel $ChannelId!"
33ExitWithExitCode 0
34}
35}
36}
37
38Write-Host "Promoting build '$BuildId' to channel '$ChannelId'."
39
40Assign-BuildToChannel -BuildId $BuildId -ChannelId $ChannelId
41
42Write-Host 'done.'
43}
44catch {
45Write-Host $_
46Write-PipelineTelemetryError -Category 'PromoteBuild' -Message "There was an error while trying to promote build '$BuildId' to channel '$ChannelId'"
47ExitWithExitCode 1
48}
49