Code Monkey home page Code Monkey logo

trigger-pipeline-from-another-pipeline's Introduction

Trigger Pipeline from another Pipeline in Azure DevOps

There are 2 solutions for triggering a pipeline from another pipeline in Azure DevOps Pipelines using yaml syntax:

  1. Using 'resources' feature
  2. Using yaml templates

Let's explore both options.

1) Trigger a pipeline from another pipeline using 'resources' feature

Here is below an example of how that works. The second pipeline will be triggered after the first one finishes successfully.

# azure-pipelines.yml
name: FirstPipeline

trigger:
- main

pool:
  vmImage: ubuntu-latest

steps:
- script: echo This pipeline runs first !
# azure-pipelines-trigger.yml
name: SecondPipeline 

trigger: none

# this pipeline will be triggered by another pipeline
resources:
  pipelines:
  - pipeline: previous-pipeline-trigger   # Name of the pipeline resource
    source: First-Pipeline-yaml # Name of the pipeline referenced by the pipeline resource
    project: Trigger-Pipeline-From-Another-Pipeline # Required only if the source pipeline is in another project
    trigger: true # enable the trigger

pool:
  vmImage: ubuntu-latest

steps:
  - script: echo This pipeline was set to be triggered after first pipeline completes.

Note how we set the trigger for the second pipeline: 'trigger: none'. This is to trigger the pipeline when only after the first one completes (i.e not after commit or PR).

More details about resources: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/resources

2) Trigger a pipeline from another pipeline using YAML Templates

# azure-pipelines.yml
name: FirstPipeline

trigger:
- main

pool:
  vmImage: ubuntu-latest

steps:
- script: echo This pipeline runs first and will trigger a second pipeline !
- template: 2_azure-pipelines-template.yml
# azure-pipelines-template.yml
steps:
- script: echo This pipeline will be triggered by another pipeline !

More details about templates: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates

trigger-pipeline-from-another-pipeline's People

Contributors

houssemdellai avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.