Pipeline is running wrong branch
Asked by schind:

Hi,

I may have found a bug in the pipelines definition.

In my project, a specific build should run for the \`feature/specific-feature\` Branch, all other feature and testing branches should have the same steps. After reading the documentation (<https://support.atlassian.com/bitbucket-cloud/docs/use-glob-patterns-on-the-pipelines-yaml-file/>), I created a separate branch pipeline for this specific branch. But when pushing to this branch, the other pipeline runs.

I tried this with an example project and a very small bitbucket-pipelines.yml:

```
image: atlassian/default-image:2

pipelines:
  default:
    - step:
        script:
          - echo "default pipeline"
  branches:
    feature/specific-feature:
      - step:
          script:
            - echo "specific feature pipeline"
    '{feature/*,testing/*}':
      - step:
          script:
            - echo "pipeline for all other feature and testing branches"
```

But, when pushing to the \`feature/specific-feature\` branch, the pipeline outputs "pipeline for all other feature and testing branches". I have attached a screenshot of the pipeline output:![campaigningbureau___branch-test___Pipelines_?_Bitbucket.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/124939i795C840A69414233/image-dimensions/842x305?v=v2 "campaigningbureau___branch-test___Pipelines_?_Bitbucket.jpg")

Could anyone help me?


Answers:
author: Theodora Boudale
body: Hi [@schind](/t5/user/viewprofilepage/user-id/950715) ,

I believe this may be a bug, as a pipeline for a specific branch should override a more generic expression that would match this branch.

I am going to reach out to the development team to confirm and will then raise a bug report.

Based on several attempts I made to reproduce and narrow down the scope of the issue, it looks that the problem is introduced when the curly brackets are used.

As a workaround, I would suggest using a yaml file like this instead:

```
image: atlassian/default-image:2

pipelines:
  default:
    - step:
        script:
          - echo "default pipeline"
  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"
```

This should work as expected. If the script for feature/\* and testing/\* has a lot of commands, you can use yaml anchors to improve readability and be able to make changes for both pipelines at the same place:

```
image: atlassian/default-image:2

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

Please feel free to let me know if this works for you, I will follow up with you also regarding the bug report.

Kind regards,  
Theodora

comments: author: schind
body: Hi [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086) ,

thanks for your response. Yes, it seems to be an issue with the curly brackets. I can confirm, that the workaround does work for me.

Do you have any update regarding the bug report already?

Best regards,

Stefan


author: Theodora Boudale
body: Hi Stefan,

You are very welcome, good to hear that the workaround works.

I got confirmation that this is indeed unintended behavior and I raised a public bug report in our issue tracker:

* <https://jira.atlassian.com/browse/BCLOUD-20732>

If you'd like to get notified via email you may add yourself as a watcher by selecting the **Start watching this issue** link in the bug report.

Bugs are fixed as per our policy [here](https://confluence.atlassian.com/support/atlassian-cloud-bug-fixing-policy-206865884.html) and when there is an update, it will get posted in that public ticket.

Please feel free to let me know if you need anything further.

Kind regards,  
Theodora


Tags: bitbucket-pipelines

bitbucket-cloud

cloud