Calling a CD pipeline from a CI pipeline
Learn how to call children pipelines from a parent pipeline
In Codefresh you can easily create nested pipelines by calling other pipelines from within an existing pipeline. This is easily accomplished with the codefresh-run plugin that 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).
The 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 3 pipelines (one parent and two children).
Create a pipeline that calls other pipelines
Here is the definition of the parent pipeline:
This pipeline does the following:
- Clones the source code with a Git clone step
- Uses cf_export to create a variable that contains the Application version as specified in
- Builds a docker image tagged with the Application version using 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 pipeline conditionals to decide if they will run or not.