Mount Environment Variables as Files

Mount environment variables as physical files.

Within a pipeline, you sometimes want to write out values or config to the file system. Traditionally you might run a bash command to do this and echo the contents into a file.

The mounts property in Sail CI allows you to map an environment variable value to a physical file within any task. This keeps pipelines lean and able to use many more native Docker images.

To use mounts first create an environment variable via https://app.sail.cifor your repository. Once you have the key for this value, you can now mount it within a task.


image: sailci/demo
- /secret/my-filename.json: ENV_VAR_KEY

In the example above, we add the mounts property to our task and set the value of this to be an array. The key of each item in the array is a path where you wish to mount the file. The value for the path is then set to the key of the environment variable (in this case ENV_VAR_KEY).


Forked repositories will not mount any environment variables to files to ensure third parties can not access secrets.