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.

Substitution runs over the raw YAML text before it is parsed, line by line. Comment lines are skipped: when the first non-whitespace character of a line is #, any ${...} on that line is left untouched.

steps:
  - name: build
    image: alpine
    commands:
      # ${CI_COMMIT_SHA} is not substituted here, this line is a comment
      - echo "building ${CI_COMMIT_SHA}"

Because this is a text-level check and not YAML parsing, it also applies to #-leading lines that YAML treats as content rather than as a comment, such as a heredoc written by a step:

steps:
  - name: write-readme
    image: alpine
    commands:
      - |
        cat > README.md <<'EOF'
        # Release ${CI_COMMIT_TAG}
        EOF

${CI_COMMIT_TAG} is not substituted on that line and ends up in README.md verbatim. Move the value onto a non-comment line if you need it interpolated.

A ${...} that is not a valid substitution expression fails the pipeline with variable substitution failed on line <n>. Bash array syntax such as ${ARRAY[@]} is the common case; escape the $ as $$ to pass it through literally.

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
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
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 events) issue-branch
CI_COMMIT_TARGET_BRANCH commit target branch (set only for pull request 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 events) 1
CI_COMMIT_PULL_REQUEST_LABELS labels assigned to pull request (set only for pull request events) server
CI_COMMIT_MESSAGE commit message Initial commit
CI_COMMIT_AUTHOR commit author username john-doe
CI_COMMIT_AUTHOR_EMAIL commit author email address john-doe@example.com
CI_COMMIT_PRERELEASE release is a pre-release (empty if event is not release) false
NAME Description Example
CI_PIPELINE_NUMBER pipeline number 8
CI_PIPELINE_PARENT number of parent pipeline 0
CI_PIPELINE_EVENT pipeline event (see event) push, pull_request, pull_request_merged, tag, …
CI_PIPELINE_URL link to the web UI for the pipeline https://ci.example.com/repos/7/pipeline/8
CI_PIPELINE_FORGE_URL link to the forge’s web UI for the commit(s) or tag that triggered the pipeline https://git.example.com/john-doe/my-repo/commit/eba09b46064473a1d345da7abf28b477468e8dbd
CI_PIPELINE_DEPLOY_TARGET pipeline deploy target for deployment events production
CI_PIPELINE_DEPLOY_TASK pipeline deploy task for deployment events migration
CI_PIPELINE_CREATED pipeline created UNIX timestamp 1722617519
CI_PIPELINE_STARTED pipeline started UNIX timestamp 1722617519
CI_PIPELINE_FILES changed 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_AUTHOR pipeline author username octocat
CI_PIPELINE_AVATAR pipeline author avatar URL https://git.example.com/avatars/5dcbcadbce6f87f8abef
NAME Description Example
CI_WORKFLOW_NAME workflow name release
NAME Description Example
CI_STEP_NAME step name build package
CI_STEP_NUMBER step number 0
CI_STEP_STARTED step started UNIX timestamp 1722617519
CI_STEP_URL UI URL for step https://ci.example.com/repos/7/pipeline/8
NAME Description Example
CI_PREV_COMMIT_SHA previous commit SHA 15784117e4e103f36cba75a9e29da48046eb82c4
CI_PREV_COMMIT_REF previous commit ref refs/heads/main
CI_PREV_COMMIT_REFSPEC previous commit ref spec issue-branch:main
CI_PREV_COMMIT_BRANCH previous commit branch main
CI_PREV_COMMIT_SOURCE_BRANCH previous commit source branch (set only for pull request events) issue-branch
CI_PREV_COMMIT_TARGET_BRANCH previous commit target branch (set only for pull request events) main
CI_PREV_COMMIT_URL previous commit link in forge https://git.example.com/john-doe/my-repo/commit/15784117e4e103f36cba75a9e29da48046eb82c4
CI_PREV_COMMIT_MESSAGE previous commit message test
CI_PREV_COMMIT_AUTHOR previous commit author username john-doe
CI_PREV_COMMIT_AUTHOR_EMAIL previous commit author email address john-doe@example.com
NAME Description Example
CI_PREV_PIPELINE_NUMBER previous pipeline number 7
CI_PREV_PIPELINE_PARENT previous pipeline number of parent pipeline 0
CI_PREV_PIPELINE_EVENT previous pipeline event (see event) push, pull_request, pull_request_merged, tag, …
CI_PREV_PIPELINE_URL previous pipeline link in CI https://ci.example.com/repos/7/pipeline/7
CI_PREV_PIPELINE_FORGE_URL previous pipeline link to event in forge https://git.example.com/john-doe/my-repo/commit/15784117e4e103f36cba75a9e29da48046eb82c4
CI_PREV_PIPELINE_DEPLOY_TARGET previous pipeline deploy target for deployment events production
CI_PREV_PIPELINE_DEPLOY_TASK previous pipeline deploy task for deployment events migration
CI_PREV_PIPELINE_STATUS previous pipeline status success, failure
CI_PREV_PIPELINE_CREATED previous pipeline created UNIX timestamp 1722610173
CI_PREV_PIPELINE_STARTED previous pipeline started UNIX timestamp 1722610173
CI_PREV_PIPELINE_FINISHED previous pipeline finished UNIX timestamp 1722610383
CI_PREV_PIPELINE_AUTHOR previous pipeline author username octocat
CI_PREV_PIPELINE_AVATAR previous pipeline author avatar URL https://git.example.com/avatars/5dcbcadbce6f87f8abef
NAME Description Example
CI_SYSTEM_NAME name of the CI system crow
CI_SYSTEM_URL link to CI system https://ci.example.com
CI_SYSTEM_HOST hostname of CI server ci.example.com
CI_SYSTEM_VERSION version of the server 2.7.0
NAME Description Example
CI_FORGE_TYPE name of forge bitbucket , bitbucket_dc , forgejo , gitea , github , gitlab
CI_FORGE_URL root URL of configured forge https://git.example.com
NAME Description
CI_SCRIPT Internal script path. Used to call pipeline step commands.
CI_NETRC_USERNAME Credentials for private repos to be able to clone data. (Only available for specific images)
CI_NETRC_PASSWORD Credentials for private repos to be able to clone data. (Only available for specific images)
CI_NETRC_MACHINE Credentials for private repos to be able to clone data. (Only available for specific images)