Просмотр исходного кода

Tag builds in release/2.2 (#1361)

* Add a script for tagging TeamCity builds

* chmod +x
Ryan Brandenburg 7 лет назад
Родитель
Сommit
115398ea8b
1 измененных файлов с 37 добавлено и 0 удалено
  1. 37 0
      scripts/Tag-TeamCityBuild.ps1

+ 37 - 0
scripts/Tag-TeamCityBuild.ps1

@@ -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