Created
January 12, 2019 20:08
-
-
Save MaxMelcher/18ef8e3cfa3113e497360ad20eefd137 to your computer and use it in GitHub Desktop.
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
#use this task to execute inline powershell in your build https://marketplace.visualstudio.com/items?itemName=petergroenewegen.PeterGroenewegen-Xpirit-Vsts-Build-InlinePowershell | |
#add the script below | |
#pass the following as arguments: -buildnumber $(Build.BuildNumber) -out $(Build.ArtifactStagingDirectory)\out.txt -guid $(System.TeamProjectId) | |
#replace the two placeholders with a Personal Access Token and your VS Account name; the part behind https://dev.azure.com/ | |
Param( | |
[string]$buildnumber, | |
[string]$out, | |
[string]$guid | |
) | |
$token = "<PAT TOKEN>" | |
$vsAccount = "<VS ACCOUNT NAME>" | |
Write-Output "BuildNumber $buildnumber" | |
Write-Output "Out $out" | |
Add-Type -AssemblyName System.Web | |
$user = "" | |
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token))) | |
$uri = "https://dev.azure.com/$vsAccount/$guid/_apis/build/builds/$buildnumber/logs/8" | |
$result = Invoke-RestMethod -Uri $uri -Method Get -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} | |
write-output $result | |
$result | out-file $out | |
write-output "##vso[task.uploadfile]$out" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment