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

Pipeline is running wrong branch

schind January 11, 2021

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

Could anyone help me?

1 answer

1 accepted

1 vote
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 12, 2021

Hi @schind ,

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

schind January 13, 2021

Hi @Theodora Boudale ,

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

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 13, 2021

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:

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 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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events