Created
October 12, 2017 15:47
-
-
Save ukcoderj/285ef8dad98c04cec35b58742a527380 to your computer and use it in GitHub Desktop.
VSTS Mark a build as retain idenfinitely (powershell)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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