Call a CD pipeline from a CI pipeline
How to call child pipelines from a parent pipeline
In Codefresh you can easily create nested pipelines by calling other pipelines from within an existing pipeline. The codefresh-run plugin allows you to launch another pipeline, and optionally wait for its completion.
A very common pattern in Codefresh is to have a parent pipeline responsible for Continuous Integration (packaging code), that calls a child pipeline for Continuous Delivery (taking care of deployment).
Example project
You can see the example project at https://github.com/codefresh-contrib/call-child-pipeline-sample-app. The repository contains a NodeJs app as well as three - one parent and two child pipelines.
Create a pipeline that calls other pipelines
Here is the definition of the parent pipeline:
codefresh.yml
This pipeline does the following:
- Clones the source code through a Git clone step.
- Creates a variable that contains the Application version as specified in
package.json
through cf_export. - Builds a docker image tagged with the Application version through a build step.
- Optionally runs the downstream QA pipeline if the branch is named
develop
. It also passes several environment variables to the child pipeline (including the Application version). - Optionally runs the downstream Prod pipeline if the branch name starts with
release
. It also passes several environment variables to the child pipeline (including the Application version).
The last two steps use conditions to decide if they will run or not.
Related articles
CI/CD pipeline examples
Codefresh YAML for pipeline definitions
Steps in pipelines
Creating pipelines
Pipeline plugins