Not every file change in our repository requires running a pipeline. For changes to files, such as README, .gitignore, and CODEOWNERS, you may not want to run 30-minute browser tests or full deployment pipelines.

To allow you to skip steps for low-impact file changes and eventually make your pipelines run faster, we are introducing a new excludePaths capability for step conditions.

Quick start

We are adding support for a excludePaths changeset condition at both the step and stage levels. To use the excludePaths changeset condition, make the following modifications to your bitbucket-pipelines.yml file:

- step:
    // Other options
    condition:
        changesets:
            excludePaths:
              - glob_pattern

If your current changes only contain files that match the excludePaths condition, the step or stage will be skipped.

Example for step-level configuration:

pipelines:
  default:
    - step:
        name: build docker image
        script:
          - docker build -t blog:latest .
        services:
          - docker
        condition:
          changesets:
            excludePaths:
              - "README.md"
              # any changes in nested directories under spec/features
              - "spec/features/**"

Example for stage-level configuration:

pipelines:
   default:
    - stage:
        name: deploy to production
        condition:
          changesets:
            excludePaths:
              - "README.md"
              - ".eslintrc.json"
        steps:
          - step:
              name: Build app
              script:
                - sh ./build-app.sh
          - step:
              name: Run unit tests
              script:
                - sh ./run-tests.sh
          - step:
              name: Deploy to production
              deployment: production
              script:
                - sh ./deploy.sh --env prod

In the pipeline details view, your skipped step or stage will appear in the UI as Skipped (shown below):

Limitations:

  • excludePaths and includePaths conditions currently can’t be used together on the same step or stage.

Please drop us a comment in the Pipelines Community Space if you have any feedback or suggestions.

Enhancements to Bitbucket Pipelines step conditions