Param( | |
[Parameter(Mandatory=$true)] | |
[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 = @{ | |
keepforever='true' | |
} | |
$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>.visualstudio.com/DefaultCollection/<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.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
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 https://www.visualstudio.com/en-us/docs/release/author-release-definition/understanding-artifacts. Blogged full context at https://intovsts.net/2016/06/26/retain-vsts-build-indefinitely/. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
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
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 https://www.visualstudio.com/en-us/docs/release/author-release-definition/understanding-artifacts. Blogged full context at https://intovsts.net/2016/06/26/retain-vsts-build-indefinitely/.