Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordotnet-maestro <@dotnet-maestro>2019-06-27 16:05:33 +0300
committerMarek Safar <marek.safar@gmail.com>2019-06-28 18:27:39 +0300
commit5da074c43ddca757b978a5816da139fc72a8ba76 (patch)
tree499b1b1ef62b088c8581c7b2aed076eb868fe18a /eng/common/post-build
parent112297ef5c076a2716c020ddb0bbf1e0a2da7703 (diff)
Update dependencies from https://github.com/dotnet/arcade build 20190626.44
- Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.19326.44 - Microsoft.DotNet.Helix.Sdk - 2.0.0-beta.19326.44
Diffstat (limited to 'eng/common/post-build')
-rw-r--r--eng/common/post-build/promote-build.ps153
1 files changed, 53 insertions, 0 deletions
diff --git a/eng/common/post-build/promote-build.ps1 b/eng/common/post-build/promote-build.ps1
new file mode 100644
index 00000000000..84a608fa569
--- /dev/null
+++ b/eng/common/post-build/promote-build.ps1
@@ -0,0 +1,53 @@
+param(
+ [Parameter(Mandatory=$true)][int] $BuildId,
+ [Parameter(Mandatory=$true)][int] $ChannelId,
+ [Parameter(Mandatory=$true)][string] $BarToken,
+ [string] $MaestroEndpoint = "https://maestro-prod.westus2.cloudapp.azure.com",
+ [string] $ApiVersion = "2019-01-16"
+)
+
+$ErrorActionPreference = "Stop"
+Set-StrictMode -Version 2.0
+
+. $PSScriptRoot\..\tools.ps1
+
+function Get-Headers([string]$accept, [string]$barToken) {
+ $headers = New-Object 'System.Collections.Generic.Dictionary[[String],[String]]'
+ $headers.Add('Accept',$accept)
+ $headers.Add('Authorization',"Bearer $barToken")
+ return $headers
+}
+
+try {
+ $maestroHeaders = Get-Headers 'application/json' $BarToken
+
+ # Get info about which channels the build has already been promoted to
+ $getBuildApiEndpoint = "$MaestroEndpoint/api/builds/${BuildId}?api-version=$ApiVersion"
+ $buildInfo = Invoke-WebRequest -Method Get -Uri $getBuildApiEndpoint -Headers $maestroHeaders | ConvertFrom-Json
+
+ if (!$buildInfo) {
+ Write-Host "Build with BAR ID $BuildId was not found in BAR!"
+ ExitWithExitCode 1
+ }
+
+ # Find whether the build is already assigned to the channel or not
+ if ($buildInfo.channels) {
+ foreach ($channel in $buildInfo.channels) {
+ if ($channel.Id -eq $ChannelId) {
+ Write-Host "The build with BAR ID $BuildId is already on channel $ChannelId!"
+ ExitWithExitCode 0
+ }
+ }
+ }
+
+ Write-Host "Build not present in channel $ChannelId. Promoting build ... "
+
+ $promoteBuildApiEndpoint = "$maestroEndpoint/api/channels/${ChannelId}/builds/${BuildId}?api-version=$ApiVersion"
+ Invoke-WebRequest -Method Post -Uri $promoteBuildApiEndpoint -Headers $maestroHeaders
+ Write-Host "done."
+}
+catch {
+ Write-Host "There was an error while trying to promote build '$BuildId' to channel '$ChannelId'"
+ Write-Host $_
+ Write-Host $_.ScriptStackTrace
+}