Tag builds in release/2.2 (#1361)

* Add a script for tagging TeamCity builds

* chmod +x
This commit is contained in:
Ryan Brandenburg 2018-08-30 13:36:01 -07:00 committed by GitHub
parent 6e33b889c0
commit 115398ea8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 37 additions and 0 deletions

37
scripts/Tag-TeamCityBuild.ps1 Executable file
View File

@ -0,0 +1,37 @@
#!/usr/bin/env pwsh
<#
.SYNOPSIS
Tags the given TeamCity build with the given tag.
.PARAMETER BuildId
The BuildId of the build to be tagged.
.PARAMETER Tag
The tag to put on this build.
#>
[cmdletbinding(SupportsShouldProcess = $true)]
param(
[Parameter(Mandatory = $true)]
[string]$BuildId,
[Parameter(Mandatory = $true)]
[string]$Tag,
[Parameter(Mandatory = $true)]
[string]$UserName,
[Parameter(Mandatory = $true)]
[string]$Password
)
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version 2
$authInfo = "${UserName}:$Password"
$authEncoded = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($authInfo))
$basicAuthValue = "Basic $authEncoded"
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", $basicAuthValue)
$headers.Add("Content-Type", "text/plain")
$uri = "http://aspnetci/app/rest/builds/$BuildId/tags/"
Invoke-WebRequest -Uri $uri -Method 'POST' -Headers $headers -Body $Tag -ErrorAction SilentlyContinue