Trigger bamboo when pull request is submitted.
Asked by jooke:

Hi,

I would like to run build in bamboo(on master branch) when some branch was merged into master branch. I need it for uploading new artifacts into Nexus. I know that exists webhooks for these trigger but this is little bit dificult. We have Jira, Bitbucket and Bamboo and everything is linked. Exists better way for this trigger (after merge to master)?

Thank you for help

Radek


Answers:
author: Jimmy Seddon
body: Hi Radek,

If I understand correctly you want a build to run only for the master branch when a pull request has been merged.

Do you allow changes to be made to the master branch if they don't come from a pull request?

I ask because you could make a clone of your current build plan that only watches for changes to the master branch and then builds and saves the artifacts whenever the master branch alone is updated.

-James

comments: author: jooke
body: *Do you allow changes to be made to the master branch if they don't come from a pull request?*

No, we don't allow changes without pull request. How to set this watching for master branch? I can't see there this option.

Radek


author: Jimmy Seddon
body: Hi Radek,

You would define this in the linked repository.

![LinkedRepository.JPG](https://community.atlassian.com/t5/image/serverpage/image-id/51510i16C1485990C2182F/image-size/large?v=v2&px=999 "LinkedRepository.JPG")


author: jooke
body: Yes, I have it but how to run this plan after merge?

![bamboo-repo.png](https://community.atlassian.com/t5/image/serverpage/image-id/51512i2105EC05DF82389B/image-size/large?v=v2&px=999 "bamboo-repo.png")

My triggers are empty and there is no option for triggering after merge.


author: Jimmy Seddon
body: Hi Radek,

On the build plan itself you will want to make sure you have a repository trigger setup there that uses your linked repository that should do what you want it to do.

![BuildPlanTrigger.JPG](https://community.atlassian.com/t5/image/serverpage/image-id/51519iCECE4D4A25156DC6/image-size/large?v=v2&px=999 "BuildPlanTrigger.JPG")


author: jooke
body: So, when is something new in master then this trigger is run? What do you have in tab Branches? I'm little bit confused with "Create plan branch".


author: Jimmy Seddon
body: I don't have anything listed for branches in this plan. By default the plan will run for the branch you have listed in the linked repository, there is no need to add a plan branch if master is all you plan to build with this.


author: jooke
body: I have following setting in branch. I don't know how to delete it.

![branch.png](https://community.atlassian.com/t5/image/serverpage/image-id/51603iFE4F79D6EF7D75A0/image-size/large?v=v2&px=999 "branch.png")


author: Jimmy Seddon
body: Hi Radek,

You don't need to delete that, those are the default setting which won't automatically create plan branches (hence the create plan branches 'manually').

You should be able to just merge a pull request into the master beanch and watch the new plan automatically pick up the new change and start building.

-James


author: jooke
body: Many thanks!


author: Aron Gombas _Midori_
body: You could use an automation rule in Jira for this use case!

Steps:

1. add the [Commit Created trigger](https://midori-global.com/products/better-devops-automation-for-jira/data-center/documentation/automation-triggers#commit-created-trigger)
2. add a condition which continues the rule only if the [{{devops.commit.isMerge}}](https://midori-global.com/products/better-devops-automation-for-jira/data-center/documentation/smart-values#devops-smart-values) smart value is true
3. [start the Bamboo build](https://midori-global.com/products/better-devops-automation-for-jira/data-center/documentation/continuous-integration/bamboo)


Tags: bitbucket

bitbucket-server

server