Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Triggering build on Bamboo for pull requests on Stash?

I want to know if it is possible to configure something similar to what is accomplished by Jenkins+Github with the request builder plugin. Specifically, triggering a build on Bamboo when a pull request is created on Stash, using the pull request branch for the build.

Bonus points for triggering new builds when the pull request is updated, or if some command is given through comments (like with the Jenkins plugin).

I can't see a way to do that, and I can't even see a way to create a plugin that will make it possible. Maybe the Merge-checks trigger for plugins would work, but it looks like something triggered when someone goes look at the pull request, not something triggered when a pull request arrives.

like image 281
Daniel C. Sobral Avatar asked Jul 10 '13 21:07

Daniel C. Sobral


People also ask

How do you trigger a bamboo build?

To configure Bamboo to trigger a build on code check-in:From the Bamboo dashboard select Builds > All build plans. Locate the plan in the list and select the edit icon ( ) to display the plan's configuration pages. Select the Triggers tab, then Add trigger. Select Remote trigger.

Which trigger will cause a build to be triggered when new changes in the source code are detected?

Repository triggers the build when changes are committed.

How do I approve a pull request in stash?

To review a pull request, select either Approve or Needs work within the header of a pull request. Click the button again or click a different one to change your status. Approving a pull request lets the author know you reviewed their changes and that you feel the work can be merged with the target branch.


1 Answers

We solved this by writing a Stash plugin, which has now been open sourced and is available on github.

The trick is to annotate methods with com.atlassian.event.api.EventListener, which will get Stash to call them when a corresponding event happens. Then just listen to events such as:

  • com.atlassian.stash.event.pull.PullRequestCommentAddedEvent
  • com.atlassian.stash.event.pull.PullRequestOpenedEvent
  • com.atlassian.stash.event.pull.PullRequestReopenedEvent
  • com.atlassian.stash.event.pull.PullRequestRescopedEvent

Aside from that, just follow Atlassian guidelines to create plugins. The open sourced plugin can serve as a reference.

like image 79
Daniel C. Sobral Avatar answered Sep 17 '22 13:09

Daniel C. Sobral