Skip to content

Instantly share code, notes, and snippets.

@horvaro
Created January 4, 2024 06:41
Show Gist options
  • Save horvaro/943138a46ebb8d0501e8964244f57ec1 to your computer and use it in GitHub Desktop.
Save horvaro/943138a46ebb8d0501e8964244f57ec1 to your computer and use it in GitHub Desktop.
Azure DevOps Pipelines: Trigger another pipeline from a pipeline in the same organization (with parameters)

You ca use the az command line tool and the built-in Access Token, when you need to trigger a pipeline inside Azure DevOps on the same Organization.

- job:
  displayName: "Run Pipeline"
  steps:
  - bash: |
      az pipelines run --project 'PROJECT' --id 123456 --branch 'main' 
    displayName: 'Trigger Pipeline 123456'
    env:
      AZURE_DEVOPS_EXT_PAT: $(System.AccessToken)

az pipelines run can also set parameters for a pipeline you want to trigger:
az pipelines run --project 'PROJECT' --id 123456 --branch 'main' --parameters 'param1=VALUE'
(The ones when you click "Run Pipeline" and can set/select in the UI in the Browser)
Documentation: https://learn.microsoft.com/en-us/cli/azure/pipelines?view=azure-cli-latest#az-pipelines-run

To find the ID of a pipeline:
az pipelines list -p "ProjectName" | ConvertFrom-Json | Select-Object -Property Id, Name, queueStatus | Where-Object { $_.Name -eq "PipelineName" }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment