An environment variable is a dynamic-named value that can affect how running processes behave.
They are part of the environment in which a process runs. For example, a running process can query
the value of the
USER environment variable to get a name of the current user, or the
USERPROFILE variable to find the directory structure owned by the user running the process.
The built-in and user-defined variables are passed to the build containers as environment variables.
They invoked in your pipelines by adding
$ in front of the variable name like as the following:
DOCKER_REGISTRY is the name of the variable to print.
Project & Repository environment variables
Repository environment variables inherit Project environment variables.
The Variables settings page can be accessed by the following path:
- Project → Project Settings → SNAKE CI → Variables
- Repository → Repository Settings → SNAKE CI → Variables
You can add, delete or modify environment variables on a project/repository level, it is be useful
for teams of any size because only a user with
admin privileges can access the Project/Repository
Variables may contain multi-line breaks, you don’t need to encode it into Base64 and decode it in the container. Just put it as is, just like that.
Pipeline & Job environment variables (YAML)
You can also specify variables using the
variables section in the pipeline.
There are two levels:
- pipeline variables — available for all jobs
- job variables — available only for the specified job
image: alpine variables: PIPELINE_WIDE: "available for all jobs" stages: - test - build run tests: stage: test variables: TEST: "available only for run tests" commands: - "echo PIPELINE_WIDE: $PIPELINE_WIDE" - "echo TEST: $TEST" compile code: stage: build variables: BUILD_FOO: "foo; only for build" commands: - "echo PIPELINE_WIDE: $PIPELINE_WIDE" - "echo TEST: $TEST" # will be empty - "echo BUILD_FOO: $BUILD_FOO"
Environment Variable Attributes
An environment variable can have several attributes:
- Masked — the value will be hidden in jobs logs.
- Secret — implies the Masked attribute, but also hides the value on the Variables page.
- Protected: will be available in the next versions: see the issue in our roadmap
A masked environment variable means that its value will be hidden in jobs logs.
Snake CI makes its best to hide the value in jobs logs, but it’s highly recommended to avoid printing the value in jobs logs.
A secret environment variable implies the Masked attribute, so it hides the value in jobs logs but it also hides the value on the Variables page.
A user can change its value by specifying a new value in the Edit Variable dialog.
A protected environment variables are not yet implemented: see the issue in our roadmap
A protected environment variables are available only on specific set of protected branches such as
Built-in environment variables CI_*
||Always equal to
||An unique pipeline ID, can be used as an identifier of the build.|
||An unique job ID.|
||The stage of the job as defined in the pipeline config.|
||The name of the job as defined in the pipeline config.|
||The branch of a commit that triggered the pipeline.|
||The tag of a commit that triggered the pipeline. Available only on tags.|
||The unique commit has of a commit that triggered the pipeline.|
||The short representation of
||The absolute path of the directory that contains the repository. Equal to the current working directory.|
||The ID of the Pull Request triggered the pipeline.|
||The key of the project which repository belongs to.|
||The name of the project which repository belongs to.|
||The unique ID of the project which repository belongs to.|
||The repository slug (can be useful for URLs)|
||The repository name.|
||The unique ID of the repository.|
||The URL used to clone the repository.|
||The unique ID of the runner where the pipeline is running.|
||The name of the runner where the pipeline is running.|
||The version of the runner where the pipeline is running.|