I have a main pipeline where I choose which stages should be triggered. This main pipeline calls other pipelines. From these pipelines there should also just be triggered the stage from the main one. I found that there is a stagesToSkip parameter. But it doesn't matter what I choose there. There will all be triggered all stages in the called pipeline. What is the error?
$targetEnvironment = 'dev'
$stages = @("dev", "staging", "prod") | Where-Object { $_ -ne $targetEnvironment } | ConvertTo-Json
$body = "{
`"stagesToSkip`" : $(ConvertTo-Json($stages))
}"
Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token"} -Method Post -Body $body -ContentType application/json
Yes, you need to fix the
stagesToSkipvalue. I added the sample below, which will only trigger the target environment dev stage, and skip staging, prod stages.Only run the target dev stage:
I used system.acccesstoken instead of pat, just need to grant
queue buildspermission for the build service account on target pipeline.Regarding your new query:
You can use rest api Runs - Run Pipeline to trigger the target pipeline, meanwhile transfer the parameter which contains the target stages. On the target pipeline, run the stages with conditions.
sample as below, main yaml, please replace target pipeline definition id with yours.
Target pipeline:
When i run the main pipeline, can specify the stages to run:
Target pipeline triggered, without staging stage.