Speed up your build with parallel steps in Pipelines

By on March 27, 2018

When we built Bitbucket Pipelines, one of our goals was to make a tool that developers love. And if there’s one thing developers love, it is getting their builds finished more quickly. Last year, we added dependency caching and detailed timing information to help speed up your builds.

Today, we’re excited to share that parallel steps are now available in Pipelines to speed up your builds even further, allowing you to run groups of tests at the same time and get your testing done faster.

The team at Paper Interactive, one of our early access customers, is already seeing the benefits of this:

Parallel steps in Pipelines has cut our CI time by two-thirds, saving our developers hours every week.” – Shane Fast, Co-founder and CTO at Paper Interactive

parallel steps bitbucket pipelines

Simple configuration

Configuring parallel steps in Pipelines is simple – just add a set of steps in your bitbucket-pipelines.yml file inside a parallel block. These steps will be started up in parallel by Pipelines so they can run independently and complete faster.

We assume you already know how to split up your tests into batches and run each batch via the command line. How you split them up is up to you – it could be unit vs integration tests, or separating a large number of similar tests into batches of even size. Some test runners can automatically split tests into batches for you, or you can just manually split tests into several test suites to see what performance benefit you will get.

Here’s a full Node.js application pipeline demonstrating an initial build step, a set of parallel testing steps, followed by a deployment step at the end:


image: node:9-alpine
 
pipelines:
  default:
    - step:
        name: Build
        script:
          - npm install
          - npm package
        artifacts:
          - dist/**  # copy these files to later steps
    - parallel:
        - step:
            name: Unit tests
            script:
              - npm run test/unit
        - step:
            name: Integration tests
            script:
              - npm run test/integration
        - step:
            name: Browser tests
            script:
              - npm run test/browserstack
    - step:
        name: Deploy to test
        deployment: test
        script:
          - npm run release --version $BITBUCKET_BUILD_NUMBER
          - npm run deploy/test

Saving your team time

The steps you configure to run in parallel will kick off at the same time in our auto-scaling build cluster, and will run to completion before the next serial step runs. It is primarily designed for large suites of automated tests, but can also be used for large compute tasks that can be parallelized.

Running steps in parallel gives you feedback faster. This saves valuable developer time that would otherwise be wasted waiting for the build. Pipelines will still bill you for all the minutes needed to execute all your parallel steps, so there’s no change to the cost of the build. (And if you run out of minutes, it’s only $10 to buy 1000 more for the month – crazy cheap compared to the developer time you’ll save.)

We’ve kept our existing limit of 10 steps per pipeline, as based on our data our customers don’t currently need more than this. We also expect running steps in parallel to have decreasing benefits beyond 10 steps, as the fixed overhead to start and stop the build starts becoming the limiting factor. If you are using Pipelines and find this limit affecting what you can run, please raise an improvement request and we’ll consider increasing this in future.

To learn more about parallel steps, see our Pipelines configuration guide.

If you have feedback about parallel steps or anything else Bitbucket related, hit us up on Twitter. Happy (parallel) building!

Try Bitbucket free