Skip to content

Instantly share code, notes, and snippets.

@ukcoderj
Created October 12, 2017 15:47
Show Gist options
  • Save ukcoderj/285ef8dad98c04cec35b58742a527380 to your computer and use it in GitHub Desktop.
Save ukcoderj/285ef8dad98c04cec35b58742a527380 to your computer and use it in GitHub Desktop.
VSTS Mark a build as retain idenfinitely (powershell)
$buildId = $env:BUILD_BUILDID # the currently running build
"Build ID: $buildId"
$keepforever = @{
keepforever='true'
}
$jsonKeepForever = $keepforever | ConvertTo-Json -Depth 100
$uriForBuildUpdate = "$($env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI)$($env:SYSTEM_TEAMPROJECTID)/_apis/build/builds/" + $buildID + "?api-version=2.0"
$result = Invoke-RestMethod -Uri $uriForBuildUpdate -Method Patch -Body $jsonKeepForever -ContentType "application/json" -Headers @{ Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN" }
Write-Verbose "Result: $result" -Verbose
"********************************"
"Build set to retain indefinitely"
"********************************"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment