Harness CI workflow configuration doesn’t allow data to be persisted across multiple stages but it is possible to share data in a particular stage with all the individual steps defined under the stage (Sharing data across stages is possible with the Caching). Shared Path support in Harness allows data to be shared across all the steps in a stage. If you want to share data between stages you need to use the cache and restore steps
Each CI stage runs in a different pod. The workspace allows you to share data between different steps in the same stage using the Shared Path configuration under the Overview settings in a pipeline.
The use case of Shared Path configuration majorly revolves around defining the working directory for the particular stage i.e all the steps defined under the stage. By default /harness is the working directory if not defined explicitly in the pipeline.
Use cases of Shared Path
- Definition of working directory
- Share additional volume
Common Examples (Will be covered in Part II)
- DinD (Docker-in-Docker)
- Storing Bazel cache to GCP bucket
- Upload non-image artifacts to GCS Bucket / AWS S3
- Save cache on VM infrastructure
Definition of working directory
As mentioned above by default Harness uses the /harness folder as the working directory but it can be changed by defining project or user specific working directory path location under the Shared Path configuration in pipeline overview settings. Here when a user adds a path they are uploaded to the stage’s temporary workspace relative to the directory specified with the root key.
For example: Specifying Shared Path configuration as “/mypath” can be referenced with /root/mypath.
Share additional volume
In Harness Continuous Integration (CI), additional volumes can be added to a pipeline by specifying the path where the volume will be mounted in the Shared Path configuration. In addition to /harness and /addon directories which are by default automatically mounted, any path you will put under the shared path configuration will be mounted explicitly.
Shared Paths by default in Harness is used to create and mount emptyDir volumes to all the containers.