Skip to content
Back to Deployment

Bitbucket Pipelines

Bitbucket-native CI/CD with bitbucket-pipelines.yml and Docker runners.

CI/CDIntermediate

Why

Bitbucket Pipelines is built into Bitbucket with bitbucket-pipelines.yml. Docker-based runners, with self-hosted runners for custom needs.

When

Use Bitbucket Pipelines for projects on Bitbucket. Avoid if not on Bitbucket.

How

1. Config — bitbucket-pipelines.yml 2. Image — Docker image for steps 3. Pipelines — default, branches, custom 4. Step — script commands 5. Caches — cache: npm for deps 6. Deployments — staging, production 7. Runner — self-hosted for custom

Example

# bitbucket-pipelines.yml image: node:20 pipelines: default: - step: { name: Test, caches: [node], script: [npm ci, npm test] } branches: main: - step: { name: Build, script: [npm ci, npm run build] } - step: name: Deploy deployment: production script: [npx vercel --prod --token $VERCEL_TOKEN]

Common Problems

  • ⚠Build minutes exceeded — free tier limited, upgrade or self-host runner
  • ⚠Deployment not working — environment not configured in repo settings
  • ⚠Configuration drift between environments — use infrastructure-as-code (Terraform/Pulumi) to keep dev/staging/prod identical

Best Practices

  • ✓Use caches for deps — speeds up builds, defined in yml
  • ✓Use deployments for env-specific — separate staging/prod with env vars
  • ✓Set up health checks and graceful shutdown — handle SIGTERM to drain in-flight requests before exit

FAQ