Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Execute bamboo spec plan only when PR is created.

Suprabhat Sinha February 27, 2025

Hi Guys,

This is my first post. Hope i get a quick response.

What i have now is:-

a build plan which run unit test with every commit pushed in feature/* branch

What i need is 

I want to create a plan which get executes only when PR is created and merge is blocked until build passes.

Im really stuggling to find out correct solution. 

Any help is really appreciated.

Thanks

Supra

1 answer

1 accepted

0 votes
Answer accepted
Shashank Kumar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 27, 2025

Hello Supra,

Welcome to Atlassian community.

A build plan which run unit test with every commit pushed in feature/* branch - This is the expected behaviour as you have trigger enabled on Bamboo and it will build the plan with each commit so this is expected, if you don't want to trigger this with each build then remove the trigger and probably set some other trigger like a scheduled trigger where frequency would be low. 

Coming to your other question

I want to create a plan which get executes only when PR is created and merge is blocked until build passes.

Here you can use the concept of plan branches, whenever a PR is created in Bitbucket Bamboo will create a new plan branch automatically and will build it. This plan will automatically get disabled once the PR is merged successfully.

Create a plan and link it to the repository on which PR will be created and then on this plan you can enable branches as shown below, whenever a PR is created it will create a new plan branch on this plan and automatic build will start on it.

Read more about it at Using plan branches , you can use the below options from Branches tab on your plan

image.png

 

I am not yet sure on you ask regarding Merging, are you talking automatic Merging from Bamboo or manual PR merge in Bitbucket or any other repo

Regards,

Shashank Kumar

Suprabhat Sinha February 27, 2025

Hi @Shashank Kumar 

Thanks for ur quick reply.

my second question is the one im trying to solve it.
So just now i did a commit and added below logic in a feature/* branch. It did triggered the build which u mentioned as above as default behaviour

branches:
create: for-pull-request

In order to stop where should i go to remove the trigger, as shown below i cannot remove trigger.

Screenshot 2025-02-27 at 9.00.25 pm.png

 
Suprabhat Sinha February 27, 2025

Screenshot 2025-02-27 at 9.09.27 pm.png

I cannot edit this. What permission should i have?

Suprabhat Sinha February 27, 2025

Screenshot 2025-02-27 at 10.42.11 pm.png

I was able to sort the issue now the plan branch looks as it needs to be. However, i deleted the PR and recreated a new PR didnt work, what am i missing?

Shashank Kumar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 27, 2025

So when you recreated the new PR, new plan branches are not created in Bamboo?

Suprabhat Sinha March 1, 2025

Hi @Shashank Kumar  

I was able to figure out what needs to be changed. Ur comment helped me a lot. 

However im getting this error now but i can do what i wanted. But this error annoys a bit
Error says - 

Update plan's branching configuration or delete existing pull request plans to enable switching the default repository.
01-Mar-2025 23:44:59 None of the override rules matched on the current branch 'dev'.
01-Mar-2025 23:45:01 com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException: Plan branch / workflow: You can't change the default repository because automatic branch management for this plan is dependent on pull request  and PR plan branches exist for this build.Update plan's branching configuration or delete existing pull request plans to enable switching the default repository.
01-Mar-2025 23:45:01 java.lang.IllegalArgumentException: com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException: Plan branch / workflow: You can't change the default repository because automatic branch management for this plan is dependent on pull request  and PR plan branches exist for this build.Update plan's branching configuration or delete existing pull request plans to enable switching the default repository.

This is my yaml

---
version: 2
plan:
project-key: REI
name: Integration Testing
key: ITEST

stages:
- Test:
manual: false
jobs:
- Test
branch-overrides:
-
stage:
stages:
- Deploy:
manual: false
jobs:
- Deploy
Deploy:
tasks:
- script:
- echo "Deploying to dev..."
- echo "Waiting...."
- sleep 3s
- echo "Deployment Successful in Dev.!!!"

Test:
key: TEST
tasks:
- script:
- echo "Validating test.."
branches:
create: for-pull-request
delete:
after-deleted-days: 7


This is what my branch config looks like
Screenshot 2025-03-02 at 12.06.22 am.png

Shashank Kumar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 3, 2025

Glad to know your issue is resolved!

Your error is explained at this community article > https://community.atlassian.com/t5/Bamboo-questions/Editing-Java-Specs-for-plans-with-active-PRs-requires-deletion/qaq-p/1332651

Probably you have old plan branches created with the old default repository and now you have probably linked a new default repository and because of which this error is coming. 

Is this scenario valid to your instance?

Regards,

Shashank Kumar

Suprabhat Sinha March 12, 2025

That got fixed thanks for all ur help. :-) 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events