Skip to content
Latchkey

How to Set Up a Monorepo Pipeline in Bitbucket Pipelines

Bitbucket runs a step only when relevant files change using the condition.changesets.includePaths key.

Add a condition: to a step with changesets.includePaths globs. The step is skipped unless the push changed a file matching one of those paths - the core monorepo lever.

Per-component change condition

Each component step runs only when files under its path changed.

bitbucket-pipelines.yml
pipelines:
  default:
    - parallel:
        - step:
            name: API
            image: node:20
            condition:
              changesets:
                includePaths:
                  - 'packages/api/**'
            script:
              - cd packages/api && npm ci && npm test
        - step:
            name: Web
            image: node:20
            condition:
              changesets:
                includePaths:
                  - 'packages/web/**'
            script:
              - cd packages/web && npm ci && npm run build

Gotchas

  • includePaths globs are evaluated against the commits in the push; the first build of a branch may run everything.
  • A step skipped by condition is shown as skipped - it does not fail, but downstream steps that need its artifacts will miss them.
  • Use for recursive matches (packages/api/); a single * does not match nested files.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →