az pipelines runs list - how to provide multiple pipeline-ids using a variable

Viewed 304

For az pipelines command, how do I provide multiple pipeline ids via variable?

This works:

az pipelines runs list --branch master --pipeline-ids 95 96

This throws parser error since the ids are concatenated as a string, but the parameter expects integer values:

$vals = "95 96"
az pipelines runs list --branch master --pipeline-ids $vals

Error:

argument --pipeline-ids: invalid int value: '95 96'

What I am trying to do is get a list of all pipeline ids, and pass it all at once, like this:

$pipelines = az pipelines list --query "[].{Name:name, Id:id}" | ConvertFrom-Json
$pipelineIds = ""
foreach ($row in $pipelines) {$pipelineIds = $pipelineIds + " " + $row.Id}
az pipelines runs list --branch master --query-order FinishTimeAsc --pipeline-ids $pipelineIds
3 Answers

You need to pass it array here. You can do this in this way:

$stringIds ="95 96"

$ids = $stringIds.Split(" ")

az pipelines runs list --pipeline-ids $ids

I found a simpler solution using my code above - use the --output tsv parameter.

$pipelineIds = az pipelines list --query "[].{Id:id}" --output tsv
az pipelines runs list --branch master --query-order FinishTimeAsc --pipeline-ids $pipelineIds

You can also try

$Ids=95,96

az pipelines runs list --pipeline-ids $Ids

Related