Reputation: 21
I am using Azure DevOps rest API to get list all releases and artifact build ID's associated with each release. The call function:
GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases?api-version=7.1-preview.8
list all releases. From there, I can get the release IDs, which I input manually into the call function:
GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases/{releaseId}?api-version=7.1-preview.8
The response from this call has artifacts, and I can get the build ID of that artifact through artifacts/definitionReference/version/id
Is there any way to get to artifacts through the list releases call? I have used $expand=$artifacts
added to the first list function, but no artifact appeared in the response.
Any advice would be appreciated.
Upvotes: 2
Views: 1139
Reputation: 76760
How to get artifacts in the response from Azure DevOps REST API call that lists all releases?
You could loop the release IDs from the first list function to get all the artifacts by the ForEach ($ReleaseId in $ReleaseIds )
.
$connectionToken="PAT"
$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($connectionToken)"))
$url = "https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases?api-version=7.1-preview.8"
$ReleaseInfo = (Invoke-RestMethod -Uri $url -Method Get -UseDefaultCredential -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)})
$ReleaseIds= $ReleaseInfo.value.id
Write-Host "ReleaseIds is = $($ReleaseIds | ConvertTo-Json -Depth 100)"
[string[]]$ReleaseIds = $ReleaseInfo.value.id
ForEach ($ReleaseId in $ReleaseIds )
{
$ArtifactsInfo= "https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases/$ReleaseId?api-version=7.1-preview.8"
$TestplanInfo = (Invoke-RestMethod -Uri $ArtifactsInfo -Method Get -UseDefaultCredential -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)})
....
}
Upvotes: 1