Missed Team ’24? Catch up on announcements here.

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

Stopping pipeline from running when a new branch is created

Sena Turku Cakmak May 2, 2024

Hey,

1) I realised that everytime someone creates a new branch from the main branch, it automatically triggers the pipeline even though nothing was changed in the repository. It gets the commit message from the last commit and reruns the entire process in the created branch. I do not want the pipeline to be triggered unless I push my changes. I don't want the pipeline to run with every new branch. How can I do it?

 

2) There is an Other (custom name) section in bitbucket while creating the branch, how can I add that branches that falls under "Other" to the yml file to run certain steps?

Thanks in advance!

 

1 answer

0 votes
Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 2, 2024

Hi @Sena Turku Cakmak 

1) If you have a default section configured in your YML configuration - this will trigger a build every single time a push is made to the repository.

The creation of a new branch involves pushing that new branch to the repository, hence why the build is triggered - for example this step would run on every single repository push (including when you create a new branch):

pipelines:
default:
- step:
name: Test
script:
- echo "Hello world!"

Therefore if you didn't want builds to run whenever you create a new branch, you'll need to remove the default section.

2) Any time you wish to trigger steps when a particular branch is pushed to, you would use the branches tag and specify its relevant branch name - for example this step would only run whenever the test branch is pushed to:

pipelines:
branches:
test:
- step:
name: Hello world
script:
- echo "Hello world!"

You can find more information regarding YML configuration below:

Hope this helps.

Cheers!

- Ben (Bitbucket Cloud Support)

Sena Turku Cakmak May 3, 2024

Thanks for the answer, but I have some questions.

 

1) We do not have a default section configured in the pipeline, but it is triggering the build when we create a new branch anyway.  The code is looking like this:

definitions:
steps:
- step: &Test
name: 'Step 1'
script:
- echo "Hello world!"


pipelines:
branches:
master:
- step: Test*

feature/*:
- step: Test*

 is there another way to fix this, or I might be missing someting?

 

2) We create branches with various names depending on the task, so it is not possible to define all the branch names in the .yml file. Is there a generalized way to address those Other branches in .yml file? I know "default" option might do the job, but if "default" in some way affects triggering the build when a branch is created as you mentioned in question 1, I do not want to trigger the build so I cannot use that.

 

Thanks for your help in advance!

Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 5, 2024

Hi Senal,

May I know what the name of the branch is that you are creating when branching from master? 

Default is the catch all for any branches that are not defined in the YML configuration, you can use wildcards to target branches starting with a particular word (as you have done with feature), but unfortunately aside from this each must be defined.

 

Cheers!

- Ben (Bitbucket Cloud Support)

Sena Turku Cakmak May 6, 2024

"May I know what the name of the branch is that you are creating when branching from master? "

It depends on what the problem is, it changes all the time, whatever the user decides :) But I think we are going to use the default option like you mentioned, thanks for the answer!

 

About my first question, is there any solution?

1) We do not have a default section configured in the pipeline, but it is triggering the build when we create a new branch anyway.  The code is looking like this:

definitions:
steps:
- step: &Test
name: 'Step 1'
script:
- echo "Hello world!"


pipelines:
branches:
master:
- step: Test*

feature/*:
- step: Test*

  

Here is an example of a situation that I encountered even though I didn't have a "default" pipeline configuration:

2024-05-06 12_41_01-.png

As you can see here, a branch called "bait" is created by me, and the pipeline is automatically triggered for #525 , with the same commit message and he same commit number from the last commit that I pushed before, #524 which is totally unrelated to #525. The only difference between them is the branch. I want to prevent #525 from happening. Is there a way for it?

Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 6, 2024

Hi Sena,

I've just noticed that you have access to a Premium workspace, so you are entitled to 1:1 Premium support directly from our support team.

I will need to gain access to your workspace to check your YML, build logs are other configurations - to do so our system requires a formal support ticket. I've just raised one on your behalf, please check your email for further correspondence.

Cheers!

- Ben (Bitbucket Cloud Support)

 

Suggest an answer

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

Atlassian Community Events