Trigger Pipelines from Other Pipelines
You can trigger one workflow from another in CircleCI by using the CircleCI API. Here's a general workflow:
-
The first pipeline is executed, makes a build, runs some tests, and triggers a deployment.
-
After that process completes successfully, the first pipeline makes an API call to CircleCI to trigger another pipeline in a different project.
-
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
- Blog: Manage complex development projects by triggering pipelines from other pipelines
- Forum Post: Caching between different workflows
Comments
Article is closed for comments.