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.

Configure extension

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
      https://vsrm.dev.azure.com/[organization name]
    • 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.

32 Replies to “Trigger a Pipeline from an Azure DevOps Pipeline”

  1. Thanks for sharing such a wonderful read on DevOps Azure information. Keep sharing such kind of worthy information.

  2. Is there a way to have the downstream pipeline to run under the same user that triggered the original pipeline?

    1. 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.

  3. Hi,

    I would like to send parameters to the pipeline. Could you please help me with this?

      1. Hello Maik,

        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 ?

        Thanks

        1. Hi Ranjit,

          Could you leave a comment an the github site? I track the feature requests and issues there.

    1. Add it trough the interface this will translate it for you to YAML. That is the easiest approach

  4. Hi Maik,

    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.

    Thanks,
    Saurabh.

    1. Hi,

      This is not possible yet. If you add this request to github I will mark it as a feature request.

  5. 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?

  6. Good stuff! Is it possible to await the triggered pipeline to finish before continuing on the original pipeline?

  7. 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!

    1. Hi Chris,

      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?

  8. 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)

    1. Yes, the first one should be possible with the extension. The second one you are mentioning is not available at this moment.

  9. 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?

  10. 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

  11. Hi Maik,
    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 ?

    1. Hi,

      That should work please create a issue on the GitHub repo and supply all info required and I will help you from there.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.