Predefined environment variables

SourceCraft automatically sets values for some environment variables. You can use them in your CI/CD processes.

Variable

Description

CI

Means that the task is running in a CI environment, which is always true.

SOURCECRAFT_CI

Means that the task is running in a SourceCraft CI/CD environment, which is always true.

SOURCECRAFT_ROOT_DIRECTORY

Path to the directory with files associated with the task in progress.

SOURCECRAFT_WORKSPACE

Path to the directory to clone the repository to. This directory is also the default directory (workdir) for cubes with a container.

SOURCECRAFT_TASK_DATA

Path to the directory housing auxiliary files of the task in progress.

SOURCECRAFT_COMMIT_REF

Full name of the branch or tag (fully-formed ref name) that caused the workflow execution, e.g., refs/heads/main or refs/tags/v1.1.

SOURCECRAFT_COMMIT_REF_NAME

Name of the branch or tag (short ref name) that caused the workflow execution, e.g., main or v1.1.

SOURCECRAFT_COMMIT_SHA

SHA hash of the commit after which the workflow started.

SOURCECRAFT_COMMIT_SHORT_SHA

First 8 characters of SOURCECRAFT_COMMIT_SHA

SOURCECRAFT_BASE_SHA

SHA hash of the commit for which the list of changes is calculated. The values it takes depend on the event that prompted the workflow execution:

  • SHA hash of the previous branch commit if pushing changes to a remote repository branch (on.push).
  • SHA hash of the last target branch commit (merge-base) if creating a pull request (on.pull_request).
  • Empty value if starting the CI/CD workflow manually (manual).

SOURCECRAFT_BASE_REF

Name of the target branch of the pull request (the branch you plan to edit), e.g., main or team/integration. Provided only when starting and restarting pull request checks.

SOURCECRAFT_EVENT

Type of the trigger event that prompted the workflow execution:

  • push: Pushing changes to a remote repository branch.
  • pull_request: Creating a pull request.
  • restart: Restarting the CI/CD process.
  • manual: Starting the CI/CD process manually.

SOURCECRAFT_CHECKOUT_ENABLED

Indicates whether or not to clone the repository automatically. It equals the checkout:enabled value. The default value is true.

SOURCECRAFT_WORKFLOW

Name of the workflow in progress.

SOURCECRAFT_TASK

Name of the task in progress.

SOURCECRAFT_CUBE

Name of the cube in progress.

SOURCECRAFT_CUBE_IMAGE

Docker image used by the cube. It is only defined for cubes which use a container.

SOURCECRAFT_CUBE_ARTIFACTS

List of paths to cube artifacts relative to SOURCECRAFT_WORKSPACE, separated with ;. It is only defined for cubes with the specified artifacts.

SOURCECRAFT_COMMIT_AUTHOR

Commit author, in Name email format.

SOURCECRAFT_COMMITTER

Committer who added the commit to the target branch, in Name email format.

SOURCECRAFT_COMMIT_TIMESTAMP

Commit timestamp in ISO 8601 format, e.g., 2025-03-03T23:41:19Z. The UTC zone is used by default.

SOURCECRAFT_COMMIT_MESSAGE

Commit message.

SOURCECRAFT_COMMIT_TITLE

Commit title, i.e., the first line of the message.

SOURCECRAFT_COMMIT_DESCRIPTION

Commit description. If the title is less than 100 characters, the message is displayed without a title; otherwise, the entire message is displayed.

SOURCECRAFT_ENV

The variable that provides environment variables from a certain cube to others as KEY=VALUE pairs. To write to such a variable, one uses >> (input redirect operator). Here is an example:

cubes:
  - name: example
    script:
      - echo "VER=1.0.1" >> $SOURCECRAFT_ENV
      - echo "VAR1=SOME_VALUE" >> $SOURCECRAFT_ENV

All cubes to execute after example will have the provided values in VER and VAR1 variables.

See also