Bitbucket Pipelines¶
Status: AI draft, 2026-11-16. Not yet verified by me. Written from the Bitbucket Cloud documentation; nothing was run.
In one line¶
Bitbucket Pipelines is the CI/CD built into Bitbucket Cloud: bitbucket-pipelines.yml defines pipelines per branch, pull request, tag or manual trigger, each step runs in a fresh container, and deployments, caches, artifacts, pipes and oidc: true cover environments, speed, reuse and keyless AWS access.
How it works¶
flowchart TD
E["Push, pull request, tag,<br/>schedule or manual run"] --> P["bitbucket-pipelines.yml:<br/>pick the matching pipeline"]
P --> S1["Step 1 in a fresh container:<br/>script, caches"]
S1 -->|"artifacts"| S2["Step 2: deployment: staging"]
S2 --> S3["Step 3: deployment: production,<br/>trigger: manual"]
image: node:22
definitions:
caches:
npm-cache: ~/.npm
pipelines:
pull-requests:
"**":
- step:
name: Test
caches: [npm-cache]
script:
- npm ci
- npm test
branches:
main:
- step:
name: Build
caches: [npm-cache]
script:
- npm ci
- npm run build
artifacts:
- dist/**
- step:
name: Deploy to staging
deployment: staging
oidc: true
script:
- ./deploy.sh staging
- step:
name: Deploy to production
deployment: production
trigger: manual
oidc: true
script:
- ./deploy.sh production
| Concept | Meaning |
|---|---|
image |
Default Docker image for steps (each step may set its own) |
pipelines |
default, branches, pull-requests, tags, custom (manual or scheduled) |
step |
One container run; script is a list of shell commands |
parallel |
Steps that run at the same time |
caches |
Predefined (such as node, pip) or custom directories kept between runs |
artifacts |
Files passed from one step to later steps in the same pipeline |
deployment |
Marks the step as a deploy to an environment (test, staging, production types), shown on the Deployments page and given that environment's variables |
trigger: manual |
Wait for someone to click before running the step |
| Variables | Workspace, repository and deployment level; secured variables are encrypted and masked in logs |
pipe |
A packaged task in a container, such as atlassian/aws-s3-deploy, configured with variables |
oidc: true |
The step gets a token in BITBUCKET_STEP_OIDC_TOKEN for AWS role assumption (OIDC from pipelines to AWS) |
| Bitbucket Pipelines | GitHub Actions | |
|---|---|---|
| File | One bitbucket-pipelines.yml |
Many files in .github/workflows/ |
| Unit of work | Step = one container | Job = one runner with steps |
| Reuse | Pipes, YAML anchors, shared pipeline configurations | Actions, reusable workflows (GitHub Actions in depth) |
| Environments | Deployments with variables, permissions and manual triggers | Environments with protection rules |
| Keyless AWS | oidc: true |
id-token: write |
| Self-hosted | Runners | Self-hosted runners |
Interview questions¶
1. Describe the structure of bitbucket-pipelines.yml.
Answer
- An optional default
image,definitions(caches, services, YAML anchors), andpipelines. - Pipelines by trigger:
default,branches,pull-requests,tags,custom. - Each contains steps with a
script, optional caches, artifacts, deployment and trigger.
2. What is the difference between caches and artifacts?
Answer
- Caches keep dependency directories between pipeline runs to save download time; not guaranteed.
- Artifacts pass build outputs from one step to later steps of the same run.
- Never rely on a cache for correctness.
3. How do deployments and variables work together?
Answer
- A step with
deployment: productionis tracked on the Deployments page and receives that environment's variables. - Secured variables are encrypted and masked.
- Combined with
trigger: manualand branch permissions, this gates production.
4. How do you deploy to AWS from Bitbucket without stored keys?
Answer
- Register the workspace's OIDC provider in IAM and create a role trusting it.
- Pin the trust policy's
subto the repository UUID and, for production, the deployment environment UUID. - Add
oidc: trueto the step and give the token to the AWS CLI or SDK throughAWS_WEB_IDENTITY_TOKEN_FILEandAWS_ROLE_ARN.
5. What is a pipe?
Answer
- A reusable, containerised task called with
pipe:and configured with variables. - Examples: deploying to S3, notifying Slack, scanning.
- Pin the pipe's version, as with any third-party action.
Sources¶
- Bitbucket Cloud: pipelines configuration reference
- Bitbucket Cloud: step options
- Bitbucket Cloud: pipeline start conditions
- Bitbucket Cloud: cache dependencies
- Bitbucket Cloud: use artifacts in steps
- Bitbucket Cloud: set up and monitor deployments
- Bitbucket Cloud: variables and secrets
- Bitbucket Cloud: what are pipes
- Bitbucket Cloud: deploy on AWS using OpenID Connect