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[organization name]
    • Release URL: The URLfor the release API for Azure DevOps this would be[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.

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

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.