Skip to content
Crow CI

Environment Variables

Environment variables can be specified for pipeline steps using the environment: section:

steps:
- name: 'step name'
image: registry/repo/image:tag
environment:
MY_ENV_VAR: 'my_value'
commands:
- echo "$MY_ENV_VAR"

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:

steps:
- name: 'step name'
image: registry/repo/image:tag
commands:
- export PATH=$PATH:/go

You can define reusable variables in the top-level variables: block of your pipeline YAML. Scalar string values defined here are available for ${...} interpolation throughout the rest of the file:

variables:
HELM_VERSION: "3.12"
UNITTEST_VERSION: "0.3.1"
steps:
- name: test
image: docker.io/helmunittest/helm-unittest:${HELM_VERSION}-${UNITTEST_VERSION}
commands:
- helm unittest .

Pipeline variables can also reference CI variables:

variables:
FULL_IMAGE: "docker.io/myorg/myapp:${CI_COMMIT_SHA}"
steps:
- name: deploy
image: ${FULL_IMAGE}
commands:
- echo "Deploying..."

Pipeline variables have lower priority than CI variables (like CI_COMMIT_BRANCH) and matrix axes, so they cannot override built-in values.

The variables: block can also be used for YAML anchors and aliases as before — non-scalar values (maps, sequences) are ignored for interpolation but work normally as anchors.

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
ActionDescriptionOriginal lueManipulated value
${VAR,}lowercase first characterVALUEvALUE
${VAR,,}lowercase all charactersVALUEvalue
${bar^}uppercase first characterbarBar
${bar^^}uppercase all charactersbarBAR
${VAR:3}extract substring from position 3 to endVALUELUE
${VAR:2:3}extract 3 characters starting from position 2VALUEAL
${VAR=FOO}set default value if VAR is unsetVALUEfoo
${VERSION##v}remove longest matching prefix pattern`v1.0.01.0.0
${FILE_TYPE%%.gz}remove shortest matching suffix pattern.tar.gz.tar
${VAR/UE/AA}replace first occurrence of UE with IIVALUEVALAA
NAMEDescriptionExample
CICI environment namecrow
CI_WORKSPACEWorkspace path where source code gets cloned to/crow/src/git.example.com/john-doe/my-repo
CI_REPOrepo full name: <owner>/<name>john-doe/my-repo
CI_REPO_OWNERrepo ownerjohn-doe
CI_REPO_NAMErepo namemy-repo
CI_REPO_REMOTE_IDrepo remote ID (= UID from forge)82
CI_REPO_URLrepo web URLhttps://git.example.com/john-doe/my-repo
CI_REPO_CLONE_URLrepo clone URLhttps://git.example.com/john-doe/my-repo.git
CI_REPO_CLONE_SSH_URLrepo SSH clone URLgit@git.example.com:john-doe/my-repo.git
CI_REPO_DEFAULT_BRANCHrepo default branchmain
CI_REPO_PRIVATErepo is privatetrue
CI_REPO_TRUSTED_NETWORKrepo “trusted network access”false
CI_REPO_TRUSTED_VOLUMESrepo “trusted volumes access”false
CI_REPO_TRUSTED_SECURITYrepo “trusted security access”false
NAMEDescriptionExample
CI_COMMIT_SHAcommit SHAeba09b46064473a1d345da7abf28b477468e8dbd
CI_COMMIT_REFcommit refrefs/heads/main
CI_COMMIT_REFSPECcommit ref specissue-branch:main
CI_COMMIT_BRANCHcommit branch (equals target branch (CI_COMMIT_TARGET_BRANCH) for pull requests)main
CI_COMMIT_SOURCE_BRANCHcommit source branch (set only for pull request events)issue-branch
CI_COMMIT_TARGET_BRANCHcommit target branch (set only for pull request events)main
CI_COMMIT_TAGcommit tag name (empty if event != tag)v1.10.3
CI_COMMIT_PULL_REQUESTcommit pull request number (set only for pull request events)1
CI_COMMIT_PULL_REQUEST_LABELSlabels assigned to pull request (set only for pull request events)server
CI_COMMIT_MESSAGEcommit messageInitial commit
CI_COMMIT_AUTHORcommit author usernamejohn-doe
CI_COMMIT_AUTHOR_EMAILcommit author email addressjohn-doe@example.com
CI_COMMIT_PRERELEASErelease is a pre-release (empty if event is not release)false
NAMEDescriptionExample
CI_PIPELINE_NUMBERpipeline number8
CI_PIPELINE_PARENTnumber of parent pipeline0
CI_PIPELINE_EVENTpipeline event (see event)push, pull_request, pull_request_merged, tag, …
CI_PIPELINE_URLlink to the web UI for the pipelinehttps://ci.example.com/repos/7/pipeline/8
CI_PIPELINE_FORGE_URLlink to the forge’s web UI for the commit(s) or tag that triggered the pipelinehttps://git.example.com/john-doe/my-repo/commit/eba09b46064473a1d345da7abf28b477468e8dbd
CI_PIPELINE_DEPLOY_TARGETpipeline deploy target for deployment eventsproduction
CI_PIPELINE_DEPLOY_TASKpipeline deploy task for deployment eventsmigration
CI_PIPELINE_CREATEDpipeline created UNIX timestamp1722617519
CI_PIPELINE_STARTEDpipeline started UNIX timestamp1722617519
CI_PIPELINE_FILESchanged files (empty if event is not push or pull_request), it is undefined if more than 500 files are touched[], [".crow.yml","README.md"]
CI_PIPELINE_AUTHORpipeline author usernameoctocat
CI_PIPELINE_AVATARpipeline author avatar URLhttps://git.example.com/avatars/5dcbcadbce6f87f8abef
NAMEDescriptionExample
CI_WORKFLOW_NAMEworkflow namerelease
NAMEDescriptionExample
CI_STEP_NAMEstep namebuild package
CI_STEP_NUMBERstep number0
CI_STEP_STARTEDstep started UNIX timestamp1722617519
CI_STEP_URLUI URL for stephttps://ci.example.com/repos/7/pipeline/8
NAMEDescriptionExample
CI_PREV_COMMIT_SHAprevious commit SHA15784117e4e103f36cba75a9e29da48046eb82c4
CI_PREV_COMMIT_REFprevious commit refrefs/heads/main
CI_PREV_COMMIT_REFSPECprevious commit ref specissue-branch:main
CI_PREV_COMMIT_BRANCHprevious commit branchmain
CI_PREV_COMMIT_SOURCE_BRANCHprevious commit source branch (set only for pull request events)issue-branch
CI_PREV_COMMIT_TARGET_BRANCHprevious commit target branch (set only for pull request events)main
CI_PREV_COMMIT_URLprevious commit link in forgehttps://git.example.com/john-doe/my-repo/commit/15784117e4e103f36cba75a9e29da48046eb82c4
CI_PREV_COMMIT_MESSAGEprevious commit messagetest
CI_PREV_COMMIT_AUTHORprevious commit author usernamejohn-doe
CI_PREV_COMMIT_AUTHOR_EMAILprevious commit author email addressjohn-doe@example.com
NAMEDescriptionExample
CI_PREV_PIPELINE_NUMBERprevious pipeline number7
CI_PREV_PIPELINE_PARENTprevious pipeline number of parent pipeline0
CI_PREV_PIPELINE_EVENTprevious pipeline event (see event)push, pull_request, pull_request_merged, tag, …
CI_PREV_PIPELINE_URLprevious pipeline link in CIhttps://ci.example.com/repos/7/pipeline/7
CI_PREV_PIPELINE_FORGE_URLprevious pipeline link to event in forgehttps://git.example.com/john-doe/my-repo/commit/15784117e4e103f36cba75a9e29da48046eb82c4
CI_PREV_PIPELINE_DEPLOY_TARGETprevious pipeline deploy target for deployment eventsproduction
CI_PREV_PIPELINE_DEPLOY_TASKprevious pipeline deploy task for deployment eventsmigration
CI_PREV_PIPELINE_STATUSprevious pipeline statussuccess, failure
CI_PREV_PIPELINE_CREATEDprevious pipeline created UNIX timestamp1722610173
CI_PREV_PIPELINE_STARTEDprevious pipeline started UNIX timestamp1722610173
CI_PREV_PIPELINE_FINISHEDprevious pipeline finished UNIX timestamp1722610383
CI_PREV_PIPELINE_AUTHORprevious pipeline author usernameoctocat
CI_PREV_PIPELINE_AVATARprevious pipeline author avatar URLhttps://git.example.com/avatars/5dcbcadbce6f87f8abef
NAMEDescriptionExample
CI_SYSTEM_NAMEname of the CI systemcrow
CI_SYSTEM_URLlink to CI systemhttps://ci.example.com
CI_SYSTEM_HOSThostname of CI serverci.example.com
CI_SYSTEM_VERSIONversion of the server2.7.0
NAMEDescriptionExample
CI_FORGE_TYPEname of forgebitbucket , bitbucket_dc , forgejo , gitea , github , gitlab
CI_FORGE_URLroot URL of configured forgehttps://git.example.com
NAMEDescription
CI_SCRIPTInternal script path. Used to call pipeline step commands.
CI_NETRC_USERNAMECredentials for private repos to be able to clone data. (Only available for specific images)
CI_NETRC_PASSWORDCredentials for private repos to be able to clone data. (Only available for specific images)
CI_NETRC_MACHINECredentials for private repos to be able to clone data. (Only available for specific images)