From within both Build & Release pipelines in Azure Devops, I'm triggering other pipelines via api.
I am trying to get my release pipeline to harvest custom variables that were discovered / used during the associated build.
I'm able to get a list of builds via get api, and i'm able to spawn other builds and pass parameters to them.
While I can spawn a release via api, I have been unsuccessful in passing parameters... or harvesting parameters on-demand at the time of Create Release.
I have reviewed Microsoft's documentation and successfully queued Builds via api with custom parameters and created releases without custom parameters.
[String]$buildID = "$env:BUILD_BUILDID"
[String]$project = "$env:SYSTEM_TEAMPROJECT"
[String]$projecturi = "$env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"
[String]$alias = "drop"
$headers = @{ Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN" }
$url= $projecturi + $project + "/_apis/release/releases?api-version=5.0-preview"
$JSON = @"
{
"definitionId": 9,
"description": "Testing API Release",
"artifacts": [
{
"alias": "$alias",
"instanceReference": {
"id": "$buildID",
"name": null
}
}
],
"isDraft": false,
"reason": "none",
"manualEnvironments": null
}
"@
Write-Host $url
$responseRelease = Invoke-RestMethod -Uri $url -headers $headers -Method Post -ContentType "application/json" -Body $JSON
Write-Host $responseRelease
The results of the current code creates a release, but don't pass custom variables (or harvest custom variables from a completed build). I would rather pass or harvest them than recalculate them.