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" }