CircleCI reference

CircleCI reference

CircleCI configs live at `.circleci/config.yml`. The required header is `version: 2.1`. The body is divided into `orbs:` (reusable bundles), `executors:` (named runner definitions), `commands:` (named groups of steps), `jobs:` (the actual work), and `workflows:` (the DAG that ties jobs together).

Expression syntax uses `<< pipeline.* >>` for pipeline values and `<< parameters.* >>` / `<< matrix.* >>` inside parameterised jobs. Built-in steps include `checkout`, `run`, `save_cache`, `restore_cache`, `store_artifacts`, `store_test_results`, `persist_to_workspace`, `attach_workspace`, and `setup_remote_docker`.

Top-level keys

KeyPurpose
versionMust be 2.1 for modern features.
orbsMap of named orb imports.
executorsNamed executor definitions.
commandsNamed groups of steps callable from jobs.
jobs.<id>.docker / machine / macosPick the executor.
jobs.<id>.stepsOrdered list of steps.
jobs.<id>.parametersJob parameters (used by matrix or by `commands:`).
jobs.<id>.parallelismTest split across N containers.
workflows.<name>.jobsList of job invocations forming the DAG.
workflows.<name>.triggersSchedule triggers; pipeline-level triggers.

Minimal example

version: 2.1

jobs:
  test:
    docker: [{ image: cimg/node:20.10 }]
    steps:
      - checkout
      - run: npm ci
      - run: npm test

workflows:
  main:
    jobs: [test]

Context variables

The same concept goes by a different name on every platform. Use this table when porting expressions and conditions.

ConceptGitHub ActionsGitLab CICircleCIBitbucket
Branch namegithub.ref_name$CI_COMMIT_REF_NAME<< pipeline.git.branch >>$BITBUCKET_BRANCH
Commit SHAgithub.sha$CI_COMMIT_SHA<< pipeline.git.revision >>$BITBUCKET_COMMIT
Tag namegithub.ref_name$CI_COMMIT_TAG<< pipeline.git.tag >>$BITBUCKET_TAG
Repository sluggithub.repository$CI_PROJECT_PATH<< pipeline.project.git_url >>$BITBUCKET_REPO_FULL_NAME
Run / pipeline idgithub.run_id$CI_PIPELINE_ID<< pipeline.id >>$BITBUCKET_BUILD_NUMBER
Triggering eventgithub.event_name$CI_PIPELINE_SOURCE<< pipeline.trigger_source >>(implicit; check pipelines.* section)
Actor / usergithub.actor$GITLAB_USER_LOGIN$CIRCLE_USERNAME$BITBUCKET_STEP_TRIGGERER_UUID
Workspace pathgithub.workspace$CI_PROJECT_DIR$CIRCLE_WORKING_DIRECTORY$BITBUCKET_CLONE_DIR
PR / MR source branchgithub.head_ref$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME$CIRCLE_BRANCH (head ref)$BITBUCKET_PR_DESTINATION_BRANCH (target only)
PR / MR target branchgithub.base_ref$CI_MERGE_REQUEST_TARGET_BRANCH_NAME(not directly exposed)$BITBUCKET_PR_DESTINATION_BRANCH

Related Tools