skip to content

Your Bitbucket Cloud workspace keeps exceeding its monthly build-minute allowance; how are Pipelines build minutes counted, and what would you change first?

level: seniorimportance: should knowfreq 18%

answer

  1. per step, not per pipeline
  2. size is a multiplier
  3. wall-clock is not the bill
  4. setup repeats in every step
  5. your own runners are not metered

basics

~20 s

Bitbucket Pipelines sums every step's run time, multiplied by step size, so a 2x step counts double. Parallel steps shorten wall-clock time, not minutes, and repeat setup. Cut unneeded runs, cache dependencies, cap max-time and move heavy steps to self-hosted runners.

solid answer

~50 s

Build minutes are the sum of each step's run time, so a pipeline's cost is per step, and a `size: 2x` step uses twice the minutes of the same step at `1x` (`4x` four times, and so on). Making steps parallel does not reduce the total; Atlassian's own wording is that minutes are calculated from the time taken by each step, and every parallel step pays its own container start, clone, cache restore and service start-up. So I would first find the expensive repositories in the workspace's Pipelines billing panel, then remove duplicate runs (overlapping `default` and `pull-requests` pipelines, steps that a `condition: changesets` could skip), add file-keyed caches for dependencies, set `max-time` well below the 120-minute default so a hung step cannot burn two hours, keep `2x` for steps that need the memory, and move long or heavy steps to self-hosted runners with `runs-on`, which are not charged build minutes.

code

yaml · 18 lines
yaml
options:
  max-time: 30
definitions:
  caches:
    deps:
      key:
        files:
          - dependencies.lock
      path: .deps
pipelines:
  pull-requests:
    '**':
      - step:
          caches: [deps]
          script: [./install-deps.sh, ./run-unit-tests.sh]
      - step:
          runs-on: [self.hosted, linux]
          script: [./run-integration-tests.sh]

go deeper

for a junior

Recall that every step's run time counts towards the workspace's monthly build-minute allowance, and that bigger step sizes count more.

for a middle

Explain how size multiplies minutes, why parallel steps do not reduce the total, and what max-time and caches do.

for a senior

Show that you find the expensive repository first, remove duplicate runs before tuning, and move heavy steps to self-hosted runners knowing what they cost instead.

for a principal

Weigh feedback time bought with parallel minutes against the bill, and when owning runner infrastructure beats paying for hosted minutes.

## How a build minute is counted Bitbucket Cloud plans include a fixed number of Pipelines **build minutes** per month for the whole workspace; on Standard and Premium, usage beyond the allowance is billed as overage. What consumes them: - **Each step's run time.** Minutes are counted per step and summed across the pipeline. Hovering over a step's duration in the pipeline view shows the minutes it used, including reruns. - **Step size as a multiplier.** A `2x` step uses twice the build minutes of a `1x` step, a `4x` step four times, and so on. - **Only Bitbucket's infrastructure.** Steps that run on your own **self-hosted runners** are not charged build minutes. | `size` | Memory for the step | Minutes per minute of run time | Availability | |---|---|---|---| | `1x` | 4 GB | 1 | every plan | | `2x` | 8 GB | 2 | every plan | | `4x` | 16 GB, plus dedicated CPUs and more disk | 4 | Standard and Premium | | `8x` | 32 GB, plus dedicated CPUs and more disk | 8 | Standard and Premium | Atlassian's billing page also announces a dated change: from 3 December 2026, annual plans will be billed for usage beyond their included allowances in the same way monthly plans already are, so an annual workspace that has been running over its allowance should expect that usage to be billed from then on. ## Why parallel steps cost more than they look The documentation says the total number of build minutes *does not change* when steps are made parallel; you see results sooner, but the minutes are the sum of each step's time. That is the floor, not the whole story, because every step is a new container that must: 1. start its image and clone the repository; 2. download the artifacts and restore the caches it needs; 3. start its service containers and wait for them; 4. only then run the part of the work you split. Split a 40-minute test step with 2 minutes of setup into eight parallel steps and each runs about 5 minutes of tests plus the same 2 minutes of setup: wall-clock time drops to about 7 minutes, while build minutes rise from 42 to about 56. Parallelism is a decision to spend minutes on feedback time, and the setup cost is what you multiply. Two more limits bound parallel designs: a pipeline can have at most 100 steps, parallel ones included, and a workspace can run only a plan-dependent number of steps at once (10 on Free; far more on Standard and Premium), beyond which excess steps fail. ## Finding where the minutes go Workspace owners and admins on monthly plans have a **Pipelines billing panel** that shows build-minute consumption **by repository** for the current and previous billing periods, and lets them open a repository's builds in chronological order to find where a spike started. Start there: a single repository with a misconfigured trigger usually explains a doubled bill better than any tuning. ## Levers, cheapest first 1. **Stop runs nobody needs.** A `pull-requests` pipeline runs *in addition to* the branch or default pipeline, so overlapping definitions run twice per push. Use `condition: changesets` with `includePaths` to skip steps whose files did not change, and remember `[skip ci]` for commits that need no build. 2. **Cache dependencies.** Custom caches under `definitions: caches`, versioned with `key: files` on a lock file, avoid re-downloading the same packages. Caches are limited to 1 GB compressed, expire after 7 days without use, and are read but not written by parallel steps, so populate them in a step before the parallel group. 3. **Cap runaway steps.** `max-time` defaults to 120 minutes and accepts 1 to 720. A hung integration test at the default burns two hours; a realistic cap set in `options` or per step ends it early. 4. **Right-size.** Give `2x` only to the step that is memory-bound, often the one with database services, rather than setting `options: size: 2x` for every step. 5. **Move heavy work to self-hosted runners.** A step with `runs-on` labels, such as `self.hosted` and `linux`, which a Linux Docker runner carries by default, runs on the next available runner of yours that has every listed label and is not charged build minutes. You pay for the machines and their operation instead; the step waits when all matching runners are busy and fails if no online runner has every label. Workspaces that choose Premium runners are billed for runner concurrency. The order matters: removing a duplicate pipeline saves every minute it used, while tuning saves a fraction.

  • What does max-time protect against, and what is its default?
    `max-time` is the longest a step may run before Bitbucket Pipelines stops it. It defaults to 120 minutes and accepts 1 to 720. Set globally under `options` or per step, a realistic cap stops a hung test or a deploy waiting on a dead endpoint from silently consuming up to two hours of build minutes.
  • What do self-hosted runners cost you instead of build minutes?
    The machines and their upkeep: capacity, patching, Docker images and network access are yours. Steps queue when every matching runner is busy and fail if no online runner carries all the requested labels. Workspaces that switch to Premium runners are also billed for the concurrency limit they set.

  • Parallel steps cut build minutes because billing follows wall-clock time.
  • A 2x step uses the same build minutes as 1x; it only adds memory.
  • Steps on self-hosted runners still draw on the workspace's build minutes.
  • A hung step is stopped after a few minutes, so max-time can be ignored.
  • Caching the build output is the main way to save build minutes.