How can I trigger one pipeline from another?

Trigger Pipelines from Other Pipelines

You can trigger one workflow from another in CircleCI by using the CircleCI API. Here's a general workflow:
  1. The first pipeline is executed, makes a build, runs some tests, and triggers a deployment.
  2. After that process completes successfully, the first pipeline makes an API call to CircleCI to trigger another pipeline in a different project.
  3. The second pipeline executes a build, runs tests, and triggers a deployment.
In this scenario, the first pipeline can also pass some pipeline parameters like the name and version of what was deployed, so that the newly triggered pipeline has some context.
Here's an example of how you can handle any parameters you pass in your jobs and workflows:
version: 2.1

parameters:
image-name:
type: string
default: "Not a real image name"

jobs:
print-image-name:
docker:
- image: cimg/base:2021.11
steps:
- checkout
- run:
name: Echo Image name
command: echo << pipeline.parameters.image-name >>

workflows:
run-workflow:
jobs:
- print-image-name

This pipeline example has a single workflow. It prints out the name of the image we built in the previous pipeline and passed via the API to this pipeline.

You can read more about triggering workflows with the v2 API and Pipeline Parameters in the CircleCI documentation and the v2 API documentation.

Additional Resources

 

 
 
 
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.