Uploaded image for project: 'Bitbucket Cloud'
  1. Bitbucket Cloud
  2. BCLOUD-22881

Exact branch match pipeline does not take precedence when using multiple glob patterns

XMLWordPrintable

      Issue Summary

      The Use glob patterns in pipelines documentation says that : 

      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.

      However, the exact branch match does not take priority when you have other branch pipeline definitions that match multiple patterns (e.g '{feature/,dev/}')

      Steps to Reproduce

      1. Create a Pipeline with multiple branch definitions and a branch exact match : 
        pipelines:
          branches:
            'dev/mybranch':
              - step:
                  script:
                    - echo "this is for branch dev/mybranch "
            '{dev/*,feature/*}':
              - step:
                 script:
                    - echo "This is from branch pattern"
        
      1. Create a branch named dev/mybranch
      2. Run the pipeline for branch dev/mybranch
      3. The pipeline for the exact match 'dev/mybranch' should be executed, but instead the pipeline ' {dev/,feature/}' is triggered.

      Expected Results

      Bitbucket pipelines should prioritize the branch exact match.

      Actual Results

      The Bitbucket Pipelines should choose the exact match pipeline, but instead, the more generic pipeline is executed.

      Workaround

      This error only affects pipeline where you have multiple glob patterns in the same definition ((e.g '{feature/,dev/}') . The workaround is to separate the patterns into individual definitions and use YAML anchors to not have to repeat the steps script :

      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 

              Unassigned Unassigned
              641e77b2eb21 Patrik S
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: