Trigger a Pipeline from an Azure DevOps Pipeline
In some situations, it can be useful to trigger an Azure DevOps pipeline from a pipeline. Triggering a pipeline can be done via the API and trough PowerShell. You can write your own script file and use the PowerShell tasks but there is also a custom task in the Azure DevOps marketplace:
With this task you can trigger a build or release pipeline from another pipeline within the same project or organization but also in another project or organization.
Personal Access Token
To get started a Personal Access Token is needed with the appropriate rights to execute pipelines. To generate a new Personal Access Token follow the below guide:
Give the personal access token the following rights depending on your scenario:
- Triggering a Release:
- Release – Read, write & execute
- Build – Read & Execute (Needed for reading the artifacts)
- Triggering a Build:
- Build – Read & execute
Copy the token for later use.
When you have installed the extension, you can start by altering a pipeline from where you want to trigger a different pipeline.
- Add a new task to the pipeline by clicking in “+” icon.
- In the task window search for “Trigger” and select the task “Trigger Azure DevOps pipeline”.
- In the task click on “New” next to Azure DevOps Service connection to create a new connection.
- In the new service connection window fill in all the correct properties.
- Connection name: The name for the connection
- Organization URL: The URL of the organization for Azure DevOps this would be https://dev.azure.com/[organization name]
- Release URL: The URLfor the release API for Azure DevOps this would be
- Personal Access Token: The personal access token that needs to be used.
- In the task choose the right options. The field for the project, build and release definitions should be filled in for you.
When you want to trigger a release for a specific version make sure to fill in the build number. When left empty the extension will use the latest version by default.
Besides that, it is also possible to trigger a build for a specific branch. When you want to make use of that option make sure you fill in the “Branch” property.
36 Replies to “Trigger a Pipeline from an Azure DevOps Pipeline”
Thanks for sharing such a wonderful read on DevOps Azure information. Keep sharing such kind of worthy information.
Is there a way to have the downstream pipeline to run under the same user that triggered the original pipeline?
That is not supported at this moment. I think that there are options to add it. Could you add it as an issue in GitHub. I will then mark it as a feature request.
Is there a way to trigger Azure DevOps pipeline from a powershell script? without using a task.
Yes, If you take a look at the Azure DevOps API you can see the options.
I would like to send parameters to the pipeline. Could you please help me with this?
Off course, could you explain your scenario?
Even I have the same scenario. I need to pass certain parameters with values to trigger another pipeline (like for example Json configuration). How can we achieve that using this tool. I do not see options for input parameters in this when i added this task. Could you please help ?
Could you leave a comment an the github site? I track the feature requests and issues there.
I’m struggling to find this github site
Also did this feature get implemented?
Awesome and easy guide! Thanks Maik!
Hi, where do I find the Release API URL? Thanks!
As specified in the post: https://vsrm.dev.azure.com/%5Borganization name]
how can i use this extension in my build pipeline(YAML based) to trigger a release pipeline
Add it trough the interface this will translate it for you to YAML. That is the easiest approach
I want see triggered pipeline result in original pipeline console. can we do that?
actually after ci cd we want to trigger smoke test pipeline but the problem is, we are unable to get result in actual pipeline.
This is not possible yet. If you add this request to github I will mark it as a feature request.
The problem with PAT is it will expire some day and service will broke. I need a solution where it don’t break things just because of PAT, as Azure DevOps not providing never expiring PAT. Can you suggest any alternative please?
Good stuff! Is it possible to await the triggered pipeline to finish before continuing on the original pipeline?
Will add that to the new functionalities list of the extension.
We have restricted the use of some pipelines because they use a service connection with elevated privileges at a subscription level. Now we can restrict any other pipelines to trigger this “protected” pipelines. but those restrictions only working in yaml. when I use your extension, I can still trigger the “protected” pipeline. is there a way to restrict that? Thanks!
The extensions uses the PAT to do the authentication. Based on those permissions it will try to invoke the pipelines. How did you configure the pipelines at this moment?
can we pass variables dynamically (at run time) from parent pipeline to child pipeline?
Is it possible to trigger a classic release pipeline via CI(build) yaml pipeline?
and also is it possible to trigger entire classic release pipeline in loop(e.g. 3-4 times)
Yes, the first one should be possible with the extension. The second one you are mentioning is not available at this moment.
Nice plugin. It is possible to trigger my Build Pipeline to use the same branch that was used to build the Artifacts in the release that I am running this trigger from?
Yes, I think that should be possible. If not please add a feature request to Github.
Hi, this is the exact plugin that I have been looking for! I have set the connection up exactly like you’ve shown above, however, I can only see Build Definitions from my project and not any of the release ones. I am trying to trigger a release pipeline within another release pipeline so any solutions would be really helpful!
Thanks in advance
Great that you like the extension! Could you share a bit more on your configuration on GitHub? I will than try to help you.
Consider a Scenario where in i have 2 Organizations ie Organization A and Organization B. My task is to trigger a Pipeline from Organization A with A pipeline in Organization B. Is there a way to Accomplish this task. We have tried the Service Connection Using Azure/TFS which is letting us connect to the Pipeline in Organization B, however its not triggering the Pipeline… Need your help on this ?
That should work please create a issue on the GitHub repo and supply all info required and I will help you from there.
It is a nice plugin to have a single pipeline that triggers multiple cd pipelines in a sequence.
Unfortunately, I am facing an issue while triggering the child pipeline from the parent pipeline if I pass the stage name. Getting the below-mentioned error.
##[error]VS402964: Transitioning of stage from state ‘InProgress’ to state ‘InProgress’ is not allowed.
Also is there any way to wait till the child pipeline completes its execution and then display the status in the parent pipeline? Because the current task\extension will show the status as ‘succeeded’, if the child pipeline got triggered. And sometimes the child pipeline might have failed and we have to check each child pipelines to verify the actual status.
Thanks, please add the problem to GitHub. I will support you there.
How do I pass build number of the parent pipeline to the pipelines getting triggered at runtime.
You should do this by adding a variable or a parameter