Home > database >  Download latest artifact from Azure Devops using Powershell - get buildId
Download latest artifact from Azure Devops using Powershell - get buildId

Time:05-07

I try to download the latest Artifact from AzureDevops with PowerShell.

Here is my script to get the latest buildid:

$organisation="aaa"
$project="bbb"
$personalAccessToken="ccc"


$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($personalAccessToken)"))
$headers = @{Authorization=("Basic {0}" -f $base64AuthInfo)}


$url = "https://dev.azure.com/$organisation/$project/_apis/build/latest/1?branchName=main" 

$result = Invoke-RestMethod -Uri $url -Method Get -ContentType application/json -Headers $headers

When I execute this, I get the exception

Build pipeline 1 was not found.

Can someone help me, where I can get the correct definitionId?

CodePudding user response:

Download latest artifact from Azure Devops using Powershell - get buildId

To get the latest artifact from the build, we need to provide the parameter definitions and the $top for the REST API enter image description here

And if you want to know the correct definitionId, you could open the pipeline in the web page, it in the URL:

enter image description here

  • Related