---
metadata:
  - name: generator
    content: Diplodoc Platform v5.54.2
alternate:
  - https://sourcecraft.dev/portal/docs/en/sourcecraft/ci-cd-ref/predefined-variables.md
  - https://sourcecraft.dev/portal/docs/ru/sourcecraft/ci-cd-ref/predefined-variables.md
  - href: en/sourcecraft/ci-cd-ref/predefined-variables.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://sourcecraft.dev/portal/docs/en/llms.txt

# Predefined environment variables

SourceCraft automatically sets values for some [environment variables](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/ci-cd.md#variables). You can use them in your [CI/CD workflows](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/ci-cd.md).

#|
|| **Variable** | **Description** ||
|| `CI` | Means that the [task](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/ci-cd.md#tasks) is running in a CI environment, which is always `true`. ||
|| `SOURCECRAFT_BASE_REF` | Name of the [pull request](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md#pr) target branch (the branch you plan to edit), e.g., `main` or `team/integration`. Provided only when starting and restarting pull request checks. ||
|| `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](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/ci-cd.md#workflows) execution:
* SHA hash of the previous branch commit if pushing changes to a remote [repository](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md#repos) 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_CALLER_ID` | UUID of the user who initiated the CI/CD workflow. For [public workflows](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/public-workflows.md), this value may differ from the user running the CI/CD workflow (`SOURCECRAFT_USERNAME`). ||
|| `SOURCECRAFT_CALLER_NAME` | Name of the user who initiated the CI/CD workflow. For [public workflows](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/public-workflows.md), this value may differ from the user running the CI/CD workflow (`SOURCECRAFT_USERNAME`). ||
|| `SOURCECRAFT_CHECKOUT_ENABLED` | Repository auto cloning indicator. It matches the [checkout:enabled](https://sourcecraft.dev/portal/docs/en/sourcecraft/ci-cd-ref/workflows.md#checkout) value. The default value is `true`. ||
|| `SOURCECRAFT_CI` | Means that the task is running in a SourceCraft CI/CD environment, which is always `true`. ||
|| `SOURCECRAFT_COMMIT_AUTHOR` | Commit author, in `Name email` format. ||
|| `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_COMMIT_MESSAGE` | Commit message. ||
|| `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_COMMIT_TIMESTAMP` | Commit timestamp in [ISO 8601](https://www.rfc-editor.org/rfc/rfc3339#appendix-A) format, e.g., `2025-03-03T23:41:19Z`. The [UTC](https://en.wikipedia.org/wiki/Coordinated_Universal_Time) zone is used by default. ||
|| `SOURCECRAFT_COMMIT_TITLE` | Commit title, i.e., the first line of the message. ||
|| `SOURCECRAFT_COMMITTER` | [Committer](https://en.wikipedia.org/wiki/Committer) who added the commit to the target branch, in `Name email` format. ||
|| `SOURCECRAFT_CUBE` | Name of the [cube](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/ci-cd.md#cubes) in progress. ||
|| `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_CUBE_IMAGE` | Docker image used by the cube. It is only defined for cubes which use a container. ||
|| `SOURCECRAFT_ENV` | The variable that provides environment variables from a certain cube to others as `KEY=VALUE` pairs. To write to the variable, the `>>` input redirect operator is used. For examples, see [these examples](https://sourcecraft.dev/portal/docs/en/sourcecraft/ci-cd-ref/env-vars-between-cubes.md#env). ||
|| `SOURCECRAFT_EVENT` | Type of the [trigger event](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/ci-cd.md#on) that prompted the workflow execution:
* `push`: Pushing changes to a remote repository branch.
* `pull_request`: Creating a pull request.
* `restart`: Restarting the CI/CD workflow.
* `manual`: Starting the CI/CD workflow manually. ||
|| `SOURCECRAFT_OUTPUT` | Variable that provides `KEY=VALUE` pairs from one cube to another via the `outputs` section. To write to the variable, the `>>` input redirect operator is used. For examples, see [SOURCECRAFT_OUTPUT](https://sourcecraft.dev/portal/docs/en/sourcecraft/ci-cd-ref/env-vars-between-cubes.md#output). ||
|| `SOURCECRAFT_PR_ID` | Unique ID ([UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier)) of the pull request within which the task was started. ||
|| `SOURCECRAFT_PR_SLUG` | Sequence number of the pull request within which the task was started, displayed in the SourceCraft interface. ||
|| `SOURCECRAFT_REPO_ID` | Unique ID (UUID) of the repository in which the current task is running. ||
|| `SOURCECRAFT_REPO_URL` | Link to the repository in `https://git@git.sourcecraft.dev/<organization_slug>/<repository_slug>.git` format. ||
|| `SOURCECRAFT_ROOT_DIRECTORY` | Path to the directory housing files associated with the task in progress. ||
|| `SOURCECRAFT_RUN_ID` | Custom SourceCraft CI/CD execution number, monotonously increasing. You can use it for versioning. ||
|| `SOURCECRAFT_TASK` | Name of the task in progress. ||
|| `SOURCECRAFT_TASK_DATA` | Path to the directory housing auxiliary files of the task in progress. ||
|| `SOURCECRAFT_TOKEN` | Token for authenticating in the [SourceCraft API](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/api-start.md) from within the CI/CD workflow. Example of getting a list of user [issues](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md#issues):

{% include [src-token-example](../../_includes/sourcecraft/ci-cd/src-token-example.md) %}

||
|| `SOURCECRAFT_USERNAME` | Name of the user running the CI/CD workflow. For [public workflows](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/public-workflows.md), this value always matches the user who marked the workflow as public (`shared: true`) and committed the changes to the main branch. In other cases, it matches `SOURCECRAFT_CALLER_NAME`. ||
|| `SOURCECRAFT_WORKFLOW` | Name of the workflow 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. ||
|#

#### Useful links {#see-also}

* [Continuous integration and continuous deployment in SourceCraft](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/ci-cd.md)
* [Configuring CI/CD in a SourceCraft repository](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/ci-cd.md)
* [Processing environment variables in SourceCraft](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/variables.md)
* [Providing environment variables from one cube to another](https://sourcecraft.dev/portal/docs/en/sourcecraft/ci-cd-ref/env-vars-between-cubes.md)

{% included (../../_includes/sourcecraft/ci-cd/src-token-example.md) %}
```yaml
on:
  push: test-workflow
workflows:
  test-workflow:
    tasks:
      - name: issues-task
        cubes:
          - name: i-have-got-issues
            script:
              - |
                curl \
                  --header "Authorization: Bearer $SOURCECRAFT_TOKEN" \
                  --url "https://api.sourcecraft.tech/me/issues"
```
{% endincluded %}