Answers: <p>You can do this with the <a href="https://marketplace.visualstudio.com/items?itemName=benjhuser.tfs-extensions-build-tasks" rel="nofollow noreferrer">Trigger Build Task</a> available from VS Marketplace.</p>
  <p>Or using <a href="https://learn.microsoft.com/en-us/rest/api/azure/devops/pipelines/runs/run-pipeline?view=azure-devops-rest-7.0" rel="nofollow noreferrer">REST API</a> methods Run pipeline. For example via <a href="https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/invoke-rest-api-v1?view=azure-pipelines&amp;tabs=yaml" rel="nofollow noreferrer">Invoke REST API</a> task or with bash (script) task:</p>
  <pre><code>- bash: |
      curl \
        -H &quot;Authorization: Bearer ${SYSTEM_ACCESSTOKEN}&quot; \
        -X POST https://dev.azure.com/{organization}/{project}/_apis/pipelines/{pipelineId}/runs?api-version=7.0
  
    displayName: Trigger another pipeline
    condition: eq(variables['IsTrigger', true])
    env:
      SYSTEM_ACCESSTOKEN: $(system.accesstoken)
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2023-01-26T12:17:10.613Z
Answers: 2023-01-26T12:17:10.613Z
Answers: Konstantin S.
Answers: <p>You could also use the <code>az</code> commandline tool and the built-in AccessToken, when you need to trigger a Pipeline inside Azure DevOps on the same Organization.</p>
  <pre class="lang-yaml prettyprint-override"><code>- job:
    displayName: &quot;Run Pipeline&quot;
    steps:
    - bash: |
        az pipelines run --project 'PROJECT' --id 123456 --branch 'main' 
      displayName: 'Trigger Pipeline 123456'
      env:
        AZURE_DEVOPS_EXT_PAT: $(System.AccessToken)
  </code></pre>
  <p><code>az pipelines run</code> can also set parameters for a pipeline you want to trigger:<br />
  <code>az pipelines run --project 'PROJECT' --id 123456 --branch 'main' --parameters 'param1=VALUE'</code><br />
  (The ones when you click &quot;Run Pipeline&quot; and can set/select in the UI in the Browser)<br />
  Documentation: <a href="https://learn.microsoft.com/en-us/cli/azure/pipelines?view=azure-cli-latest#az-pipelines-run" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/cli/azure/pipelines?view=azure-cli-latest#az-pipelines-run</a></p>
  <p>To find the ID of a pipeline:<br />
  <code>az pipelines list -p &quot;ProjectName&quot; | ConvertFrom-Json | Select-Object -Property Id, Name, queueStatus | Where-Object { $_.Name -eq &quot;PipelineName&quot; }</code></p>
  
Answers: CC BY-SA 4.0
Answers: 2024-01-04T06:32:58.323Z
Answers: 2024-01-04T06:32:58.323Z
Answers: horvaro
Answers: <p>you can do by adding a trigger to the pipeline that you want to be triggered like</p>
  <pre><code>
  resources:
    'pipelines:
    - pipeline: MyCIAlias  
      source: MainPipeline
      trigger:    
        stages:        
        - MyStage
  </code></pre>
  <p>This will be triggered when the stage &quot;MyStage&quot; in your pipeline &quot;MainPipeline&quot; has completed.</p>
  <p>In the MainPipeline on the MyStage you can set a condition that will skip the stage unless your &quot;IsTrigger&quot; variable is set to true, like</p>
  <pre><code>- stage: MyStage 
    dependsOn: 
    - Build
    displayName: Checklist Pre Production Release
    condition: | 
      eq(variables.IsTrigger, 'true')
      ```
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2023-01-25T09:50:59.690Z
Answers: 2023-01-25T09:50:59.690Z
Answers: qBasicBoy
Body: <p>If I create a variable like IsTrigger and the default value of this variable is false and this value can be set at queque time.</p>
  <p>I wonder what happens if I give this variable true as value when I run a pipeline.</p>
  <p>Can I trigger a different pipeline based on the value of this variable?</p>
  <p>for example:</p>
  <pre><code>    eq(variables['IsTrigger', true]
  </code></pre>
  <ul>
  <li>do trigger different pipeline</li>
  </ul>
  
Tags: <azure-devops>
Title: Is there any way to trigger a different pipeline inside of a pipeline in Azure Dev Ops
UserDisplayName: user20732118
ThreadText: # Is there any way to trigger a different pipeline inside of a pipeline in Azure Dev Ops
  
  (Asked by: username_0 on 2023-01-23)
  
  If I create a variable like IsTrigger and the default value of this variable is false and this value can be set at queque time.
  
  I wonder what happens if I give this variable true as value when I run a pipeline.
  
  Can I trigger a different pipeline based on the value of this variable?
  
  for example:
  
  ```
      eq(variables['IsTrigger', true]
  
  ```
  
  * do trigger different pipeline
  
  **Tags:** azure-devops
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2023-01-26. Score: 1 | Accepted answer
  
  You can do this with the [Trigger Build Task](https://marketplace.visualstudio.com/items?itemName=benjhuser.tfs-extensions-build-tasks) available from VS Marketplace.
  
  Or using [REST API](https://learn.microsoft.com/en-us/rest/api/azure/devops/pipelines/runs/run-pipeline?view=azure-devops-rest-7.0) methods Run pipeline. For example via [Invoke REST API](https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/invoke-rest-api-v1?view=azure-pipelines&tabs=yaml) task or with bash (script) task:
  
  ```
  - bash: |
      curl \
        -H "Authorization: Bearer ${SYSTEM_ACCESSTOKEN}" \
        -X POST https://dev.azure.com/{organization}/{project}/_apis/pipelines/{pipelineId}/runs?api-version=7.0
  
    displayName: Trigger another pipeline
    condition: eq(variables['IsTrigger', true])
    env:
      SYSTEM_ACCESSTOKEN: $(system.accesstoken)
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2024-01-04. Score: 0
  
  You could also use the `az` commandline tool and the built-in AccessToken, when you need to trigger a Pipeline inside Azure DevOps on the same Organization.
  
  ```yaml
  - 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" }`
  
  
  ---
  
  ### Answer by username_3 on 2023-01-25. Score: 0
  
  you can do by adding a trigger to the pipeline that you want to be triggered like
  
  ```
  
  resources:
    'pipelines:
    - pipeline: MyCIAlias  
      source: MainPipeline
      trigger:    
        stages:        
        - MyStage
  
  ```
  
  This will be triggered when the stage "MyStage" in your pipeline "MainPipeline" has completed.
  
  In the MainPipeline on the MyStage you can set a condition that will skip the stage unless your "IsTrigger" variable is set to true, like
  
  ```
  - stage: MyStage 
    dependsOn: 
    - Build
    displayName: Checklist Pre Production Release
    condition: | 
      eq(variables.IsTrigger, 'true')
      ```
  
  ```
  
  
  ---
  
  