-
Notifications
You must be signed in to change notification settings - Fork 0
/
SetBuildQuality.ps1
40 lines (32 loc) · 1.04 KB
/
SetBuildQuality.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
param
(
[string] $RestToken="",
[string] $BuildID="",
[string] $BuildTags=""
)
$buildTagsArray = $BuildTags.Split(";");
$baseurl = "$($env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI)DefaultCollection/$($env:SYSTEM_TEAMPROJECT)/_apis"
$token =""
IF([string]::IsNullOrEmpty($env:System_AccessToken)) {
Write-Host "No System Access Token. Sending RESTToken"
$userpass = ":$($RestToken)"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($userpass))
$token = "Basic $encodedCreds"
}
else
{
Write-Host "System Access Token Found."
$token = "Bearer $($env:System_AccessToken)"
Write-Host $token
}
Write-Host "BaseURL: [$baseurl]"
Write-Host "tagURL: [$tagURL]"
Write-Host "token: [$token]"
if ($buildTagsArray.Count -gt 0) {
foreach($tag in $buildTagsArray)
{
$tagURL = "$baseurl/build/builds/$BuildID/tags/$tag`?api-version=2.0"
$response = Invoke-RestMethod -Uri $tagURL -Headers @{Authorization = $token} -Method Put
Write-Host $response
}
}