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

A pipeline definition for a specific branch does not override a more generic expression when curly brackets are used

    XMLWordPrintable

Details

    Description

      Issue Summary

      If a user specifies the exact name of a branch, a tag, or a bookmark in their yml file, the pipeline defined for the specific branch should override any more generic expressions that would match that branch.

      This is not the case when the more generic expression is included in curly brackets.

      Steps to Reproduce

      1. Create a Bitbucket Cloud repo
      2. Create and commit in the repo a bitbucket-pipelines.yml like the following
         image: atlassian/default-image:2
        
         pipelines:
           branches:
             feature/specific-feature:
               - step:
                   script:
                     - echo "specific feature pipeline"
             '{feature/*,testing/*}':
               - step:
                   script:
                     - echo "pipeline for all other feature and testing branches"
         
      1. Create from Bitbucket UI a branch named feature/specific-feature

      Expected Results

      The pipeline for feature/specific-feature runs

      Actual Results

      The pipeline for feature/* runs instead

      Workaround

      Since the issue occurs when curly brackets are used in the generic expression, you can work around this issue by adjusting the bitbucket-pipelines.yml file to not use curly brackets.

      E.g. for the example bitbucket-pipelines.yml above, it could be as follows:

      image: atlassian/default-image:2
      
      pipelines:
        branches:
          feature/specific-feature:
            - step:
                script:
                  - echo "specific feature pipeline"
          feature/*:
            - step:
                script:
                  - echo "pipeline for all other feature and testing branches"
          testing/*:
            - step:
                script:
                  - echo "pipeline for all other feature and testing branches"
      

      Or using yaml anchors as follows:

      image: atlassian/default-image:2
      
      definitions:
        steps:
          - step: &feature-testing
              script:
                - echo "pipeline for all other feature and testing branches"
                
      pipelines:
        branches:
          feature/specific-feature:
            - step:
                script:
                  - echo "specific feature pipeline"
          feature/*:
            - step: *feature-testing
          testing/*:
            - step: *feature-testing
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            tboudale Theodora Boudale
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: