I have a pipeline that we trigger from the web interface when we want to create a release and it looks something like this:
parameters:
- name: release
displayName: Release
type: string
default: No
values:
- No
- Dev
- Prod
trigger: none # will disable CI builds entirely
pool:
vmImage: "ubuntu-latest"
variables:
- template: pipelines/variables/flutter_variables.yaml
- template: pipelines/variables/android_variables.yaml
parameters:
releaseMode: ${{ parameters.release }}
- template: pipelines/variables/ios_variables.yaml
parameters:
releaseMode: ${{ parameters.release }
stages:
...
Upon completion of this pipeline I want to trigger another run of the the pipeline, but only if the parameter release is set to Prod
and the second run of the pipeline should run with that parameter set to Dev
.
Is it possible to do this with yaml, or does one have to use a script using az
as the last step of the pipeline, and in that case what would that script look like?
2
Answers
We used the following stage as our last step to trigger the rebuild with a different parameter:
It only triggers when the current pipeline is running with the release parameter set to
Prod
and when the other stages have succeeded.Instead of using az pipeline build queue command use the az pipelines run, in this command you can specify the pipeline parameter
The following is the working example:
NOTE: in order for your pipeline to run another pipeline you need to assign the queue builds permission to the ADO Project Build Service user.
Verification:
Run the pipeline with the Release parameter set to Prod.
Results:
Both stages will be executed in the pipeline, after successful pipeline execution another pipeline run will be queued with the Release parameter set to Dev and only one EmptyStage will be started in the second run.