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.

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

      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

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

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

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

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

Leave a Reply

Your email address will not be published. Required fields are marked *

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