Codefresh offers its own built-in format for creating pipelines. The pipeline specification is based on the YAML syntax allowing you to describe your pipelines in a completely declarative manner.
Using Codefresh yaml is the recommended way to create pipelines.
Simple example for codefresh.yml
Here is a very minimal example:
It contains two steps, one named build_image that creates a docker image, and another one called perform_tests that runs unit test with
If you want to know more about how steps work in Codefresh make sure to read the introduction to Pipelines first, before moving on.
Basic skeleton of a codefresh.yml file.
You can customize your build environment (pipeline) by using the Codefresh YAML file,
codefresh.yml. Codefresh uses the build specifications in the
codefresh.yml file to execute your build. The
codefresh.yml can be basic, or include intricate build specifications.
A YAML file is comprised of a series of steps that are executed in the order in which they are specified.
You must define a step type for each step. Each step uses Docker images and containers as facilitators for execution. For example, the Freestyle step spins up a container and executes the specified shell commands from the YAML file.
Each step produces a resource, which you can reference in other steps, and are executed in real-time. For example, a Freestyle step can reference an image that was produced by a Build step. This allows you to chain steps together, and create highly-customized builds.
Steps chaining and referencing is possible due to implementation of variables in yml file - read more on relevant section
|Build||Builds a Docker image.|
|Push||Pushes a Docker image to a Docker registry.|
|Git Clone||That step not required and added automatically|
|Composition||Start a finite Docker Composition.|
|Launch Composition||Start a long term Docker composition|
|Freestyle||Execute one or more shell commands.|
To build your pipeline using a
codefresh.yml file, in the General Settings section, toggle the
Use YML build option to the ON position.
Grouping steps with pipeline stages
By default all pipeline steps are shown one after the other.
This view works ok for small pipelines, but for a big number of steps it is better to group them into pipeline stages like shown below:
The number of stages (i.e columns) and their titles is completely configurable.
To enable this view you need to make two modifications at the
Here is the skeleton:
As you can see the modifications needed are:
- List all the stage names at the root of the pipeline file
- Use the
stageproperty on each step to assign it to a stage.
This updated pipeline view is only a nice way to visualize the pipeline. It does not affect the order of step execution. Steps will still execute in the same order listed in the
Here is a more concrete example that you can use as a starting point:
If you run the pipeline you will see this view
Remember that the assignment of a step to a stage is happening only for graphical grouping purposes. It does
not affect the way your steps run. All steps will still run in the same order mentioned in the
Also notice if you enable this view a stage called default will show all build steps that are not explicitly assigned to a stage.