Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

What is the rules for the order of branch pipelines?

Jeremy Richardson September 11, 2023

I have a repo that has a couple branches with unique build scripts. From what I can tell the documentation says that the more specific the branch name used, the higher priority it will be in getting called.

If you specify the exact name of a branch, a tag, or a bookmark, the pipeline defined for the specific branch overrides any more generic expressions that would match that branch.

https://support.atlassian.com/bitbucket-cloud/docs/use-glob-patterns-on-the-pipelines-yaml-file/

But for some reason this glob based expression always overrides my pipeline where I specific the specific branch name. The branch I want to run is dev/pagespeed.

dev/pagespeed // this is what I want to run
"{feature/*,fix/*,dev/*}" // this one runs...

1 answer

1 accepted

0 votes
Answer accepted
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 12, 2023

Hello @Jeremy Richardson and thank you for reaching out to Community!

I was able to confirm that when using multiple patterns in a branch pipeline definition (e.g. '{feature/*,fix/*,dev/*}')  the order of priority of branch exact match is not working correctly.

For that, I raised a bug report to our development team so this can be fixed : 

I would suggest you to add your vote there, since this helps both developers and product managers to understand the impact. Also, make sure you add yourself as a watcher in case you want to receive first-hand updates from that ticket. Please note that all bug fixes are implemented with this policy in mind.

In the meantime, you can try using the workaround I described in the bug ticket. From my tests, the issue seems to only occur when the branch running the pipeline has both an exact match and a generic match that has multiple patterns. With that in mind, I was able to get it working separating the glob patterns by their own definitions. To avoid repeating the step's script and other attributes for each of the definitions, you can make use of YAML anchors. Following is an example definition using those concepts : 

definitions: 
  steps:
    - step: &build-test
        name: Build and test
        script:
          - mvn package
        artifacts:
          - target/**
pipelines:
  branches:
     'dev/mybranch':
      - step:
          script:
            - echo "this is for branch dev/mybranch "
     'dev/*' :
      - step: *build-test
     'feature/*':
      - step: *build-test 

Hope that helps! Let me know in case you have any questions.

Thank you, @Jeremy Richardson !

Patrik S

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events