Share data between pipeline steps
How to cache folders between steps and builds
Codefresh creates a shared volume in each pipeline that is automatically shared with all freestyle steps.
This volume exists at
/codefresh/volume by default. Simply copy files there to have them available to all Codefresh steps (as well as subsequent builds of the same pipeline).
The Git clone step deletes any files not specified in
.gitignore. To cache a folder that exists in your project directory (such as
node_modules), you must also add it to
Using the shared volume
You can see the example project at https://github.com/codefreshdemo/cf-example-shared-volumes-between-builds. The repository contains a simple application, a Dockerfile, and an example pipeline that saves/reads a dummy file to the Codefresh volume.
Here is the whole pipeline:
This pipeline does the following:
- Clones the source code through a Git clone step.
- Builds a docker image through a build step.
- Copies the file
artifact.exampleto the volume through a freestyle step.
- Reads the contents of the volume through a different freestyle step.
If you run the pipeline, you will see the file contents in the fourth step:
If you run the pipeline a second time, you will see the dummy file in all steps, as the volume is automatically cached for subsequent builds as well.