How to keep your pipelines DRY
After creating several pipelines in Codefresh you will start to notice several common values between them. Common examples are access tokens, environment urls, configuration properties e.t.c.
Codefresh allows you to create those shared values in a central place and then reuse them in your pipelines avoiding the use of copy-paste.
You can share:
- Environment parameters (easy)
- Helm values (easy)
- Any kind of YAML data (advanced)
Creating shared configuration
From the left sidebar click Account settings to enter your global settings. Then choose Shared Configuration from the left menu.
You can create two types of shared configuration:
- Shared configuration/ Shared secret
- yaml/ secret yaml
The shared configuration is for environment variables. The secret variant is the same thing but with encrypted values for sensitive data (such as access tokens).
The shared yaml is for Helm value or any other generic information. The secret yaml encrypts the contents.
You can create as many shared snippets as you want (with unique names).
Using shared environment variables
Each pipeline has a set of environment variables that can be defined in its configuration screen.
To use your shared configuration, click the import button and select the snippet from the list:
Once you click Select the values from the shared configuration will be appended to the ones you have in your pipelines. In case of similar values the shared configuration will follow the precedence rules.
Using shared Helm values
To use a shared YAML snippet for Helm values you can install a new Helm chart either from
In both cases, when you see the Helm installation dialog you can import any of your YAML snippets to override the default chart values.
From the same dialog you can also create a brand new shared configuration snippet of type YAML. Not only it will be used for this Helm chart, but it will be added in your global shared configuration as well.
Sharing any kind of YAML data in pipelines
All the snippets from shared configuration are also available as context in the Codefresh CLI
This means that you can manipulate them programmatically and read their values in the pipeline in any way you see fit.
If for example you have a shared configuration named
my-global-config you can easily read its contents programmatically using the CLI:
Example - custom value manipulation
Let’s say that you have a YAML segment with the following contents:
Here is a pipeline step that is reading the yaml snippet and extracts a value
Once the pipeline runs, you will see in the logs:
I love eating pizza