Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
[string] $PATPassword
$username = "POC-GetBuildDetails"
$basicAuth = ("{0}:{1}" -f $username,$PATPassword)
$basicAuth = [System.Text.Encoding]::UTF8.GetBytes($basicAuth)
$basicAuth = [System.Convert]::ToBase64String($basicAuth)
$headers = @{Authorization=("Basic {0}" -f $basicAuth)}
$keepforever = @{
$jsonKeepForever = $keepforever | ConvertTo-Json
#Get Build ID from text file (same folder as powershell script)
$buildID = Get-Content -Path "BuildId.txt"
Write-Verbose "Build ID from Artefact Build ID text file: $buildID" -Verbose
$uriForBuildUpdate = "https://<vstsaccount><TeamProject>/_apis/build/builds/" + $buildID + "?api-version=2.0"
Write-Verbose "Assembling uri for build update: $uriForBuildUpdate" -Verbose
$result = Invoke-RestMethod -Uri $uriForBuildUpdate -headers $headers -Method Patch -Body $jsonKeepForever -ContentType "application/json"
Write-Verbose "Result: $result" -Verbose
Write-Verbose "Build Artifact marked as retain indefintely ..." -Verbose

This comment has been minimized.

Copy link
Owner Author

pietergheysens commented Jun 26, 2016

The Build ID can now be fetched directly via the build artifact link => use environment variable $env:RELEASE_ARTIFACTS[source-alias][variable-name]. Read more about the artifact variables at Blogged full context at


This comment has been minimized.

Copy link

HockeyJustin commented Oct 12, 2017

Great starter - thanks. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.