Bitbucket Pipelines reference

Bitbucket Pipelines reference

Bitbucket Pipelines is configured via `bitbucket-pipelines.yml` at the repository root. The file declares a global `image:`, optional `definitions:` (services and custom caches), and a `pipelines:` map keyed by trigger type — `default`, `branches`, `tags`, `pull-requests`, and `custom` (manual). Each value is a list of `step:` (or `parallel:`) entries.

There are no expressions like the other platforms — Bitbucket uses simple shell-style `$VAR` interpolation. Built-in caches include `node`, `pip`, `composer`, `gradle`, `maven`, `bundler`, `dotnetcore`, `sbt`, `ivy2`, `ruby`. Pipes (`pipe: org/name:version`) are reusable Docker-based steps with a YAML wrapper.

Top-level keys

KeyPurpose
imageGlobal default Docker image.
cloneGit clone configuration (depth, lfs).
definitions.servicesSidecar service containers usable from steps.
definitions.cachesCustom cache name → path mapping.
pipelines.defaultSteps that run on every push.
pipelines.branches.<glob>Steps that run on push to matching branches.
pipelines.tags.<glob>Steps that run on push of a matching tag.
pipelines.pull-requests.<glob>Steps that run on PRs targeting matching branches.
pipelines.custom.<name>Manually-triggered named pipeline.
step.imageOverride image for this step.
step.scriptList of commands to run.
step.cachesList of cache names to restore + save.
step.artifactsList of glob paths to persist for downstream steps.
step.trigger"manual" gates the step on user click.
step.deploymentBitbucket deployment environment (configured in the UI).

Minimal example

image: node:20

definitions:
  caches:
    npm: ~/.npm

pipelines:
  default:
    - step:
        name: test
        caches: [npm]
        script:
          - npm ci
          - npm 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