The environment section is not able to expand variables. If this is needed (e.g., to alter $PATH), the variable should be defined (and exported) in the commands section:
${<variable>} expressions are subject to pre-processing of the YAML parser. If this is not desired, the variable must be escaped via $$, resulting in $${<variable>}.
String Substitution
String Operations
Bash string operations are supported to manipulate env vars. The manipulation happens before the variable substitution.
The table below lists supported actions including examples:
Variables:
VAR: VALUE
bar: bar
FOO: foo
VERSION: v1.0.0
FILE_TYPE: .tar.gz
Action
Description
Original lue
Manipulated value
${VAR,}
lowercase first character
VALUE
vALUE
${VAR,,}
lowercase all characters
VALUE
value
${bar^}
uppercase first character
bar
Bar
${bar^^}
uppercase all characters
bar
BAR
${VAR:3}
extract substring from position 3 to end
VALUE
LUE
${VAR:2:3}
extract 3 characters starting from position 2
VALUE
AL
${VAR=FOO}
set default value if VAR is unset
VALUE
foo
${VERSION##v}
remove longest matching prefix pattern
`v1.0.0
1.0.0
${FILE_TYPE%%.gz}
remove shortest matching suffix pattern
.tar.gz
.tar
${VAR/UE/AA}
replace first occurrence of UE with II
VALUE
VALAA
Default environment variables
General
NAME
Description
Example
CI
CI environment name
crow
CI_WORKSPACE
Workspace path where source code gets cloned to
/crow/src/git.example.com/john-doe/my-repo
CI_REPO
repo full name: <owner>/<name>
john-doe/my-repo
CI_REPO_OWNER
repo owner
john-doe
CI_REPO_NAME
repo name
my-repo
CI_REPO_REMOTE_ID
repo remote ID (= UID from forge)
82
CI_REPO_URL
repo web URL
https://git.example.com/john-doe/my-repo
CI_REPO_CLONE_URL
repo clone URL
https://git.example.com/john-doe/my-repo.git
CI_REPO_CLONE_SSH_URL
repo SSH clone URL
git@git.example.com:john-doe/my-repo.git
CI_REPO_DEFAULT_BRANCH
repo default branch
main
CI_REPO_PRIVATE
repo is private
true
CI_REPO_TRUSTED_NETWORK
repo "trusted network access"
false
CI_REPO_TRUSTED_VOLUMES
repo "trusted volumes access"
false
CI_REPO_TRUSTED_SECURITY
repo "trusted security access"
false
Current Commit
NAME
Description
Example
CI_COMMIT_SHA
commit SHA
eba09b46064473a1d345da7abf28b477468e8dbd
CI_COMMIT_REF
commit ref
refs/heads/main
CI_COMMIT_REFSPEC
commit ref spec
issue-branch:main
CI_COMMIT_BRANCH
commit branch (equals target branch (CI_COMMIT_TARGET_BRANCH) for pull requests)
main
CI_COMMIT_SOURCE_BRANCH
commit source branch (set only for pull_request and pull_request_closed events)
issue-branch
CI_COMMIT_TARGET_BRANCH
commit target branch (set only for pull_request and pull_request_closed events)
main
CI_COMMIT_TAG
commit tag name (empty if event != tag)
v1.10.3
CI_COMMIT_PULL_REQUEST
commit pull request number (set only for pull_request and pull_request_closed events)
1
CI_COMMIT_PULL_REQUEST_LABELS
labels assigned to pull request (set only for pull_request and pull_request_closed events)