It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Can I notify Jenkins of a pull request?

During our daily development, the architecture group receives a fair number of pull requests. Ideally, as part of the review process on these pull requests, we would check out the code locally and run all the tests to ensure that the commit doesn't break the build. In reality, that's way too time consuming and we just go on blind faith that the developer in charge of the modification has already ensured all the tests pass. As you can guess, that's not always the case.


What I'm wondering is, would it be possible for you to implement a process that kicks off a Jenkins job to test the pull requests before the code is merged into master? That way, the architecture team could know at a glance if the PR passed all the tests, and it would save us all time in reviewing something that may not be working.

5 answers

0 votes
ThiagoBomfim Atlassian Team Jan 28, 2015

Hi Ashish,

This is going to be a long answer, but I am hoping we can help one another here.

You can currently see the status of your Pull Request before merging it using the UI when you're integrating with Bamboo. Please have a look at:

Currently Bamboo has an option so it will build a branch every time a change is pushed to that branch/repo

You can read more about this on:

When you create a plan that uses a linked Stash repository, with Stash 3.1 and later, Bamboo uses the 'Stash repository triggers the build when changes are committed' trigger option by default.

Because of this integration with Bamboo allied with the concept of "Plan Branches" in the tool (link above), when Build builds/notifies Stash about the build result of the PR's "origin branch", this is an example of how a PR looks like in Stash:



The image above means that 3 different systems built the "origin branch" of that PR successfully and that'd be ok to merge it back into master.

I told you the Bamboo story to come back to your question which is now: how to do I accomplish the same results with Jenkins?

In order to notify Jenkins so it will start building the Stash repo after changes are pushed, there is a plugin in Marketplace that could help you:

The link to its documentation can also be found there:

with these plugins (you need one in Stash and another one in Jenkins itself as per the documentation above) you will be able to set this up as well for Jenkins (notify Jenkins that is time to build because changes have been pushed to a repo and get the build result displayed by Stash).

Once I had a question from a customer about "how to build a specific branch using Jenkins".

My knowledge of the tool is inexistent (sorry about that). However, after searching I answered this customer that this concept doesn't appear to exist and customers are applying the workaround described here:

On the other hand, the same customer came back to me saying:

So I am working with the plugin [Stash Webhooks to Jenkins], and I figured out that you can have it build a certain branch by specifying which branch you want to build in the Git step of the Jenkins job.

I honestly don't know which one of the above is correct or more appropriate – I know that's what you need to accomplish. In theory, if you can make Jenkins build the "origin branch" of the PR and notify Stash about its result, you should get the same screen I showed you for Bamboo for the PR with its result.

I am hoping this answer helps you and that you're able to enlighten the community with your findings about Jenkins. 

Let us know how you go! :smile:

Thiago Bomfim

Hi Thiago,


Thanks for the info. I did install the following plugins:


STASH: Stash Webhook to Jenkins

Jenkins: Stash Notifier Plugin


I am able to have Jenkins notify STASH via a checkmark the status of a build. The only thing, I can’t get working with the ‘Stash Webhook’ plugin is to build (trigger) a job on a pull request. I think it is some configuration on Stash’s Refspec and Build Branch.


Do you have any ideas on that?


Here is what I see on the STASH server:









Which Refspec do I use and what is the Syntax??

My branch is NOT 'origin master'. It is 'origin newbranch'





0 votes
ThiagoBomfim Atlassian Team Jan 29, 2015

Hi Ashish,

Sorry, I don't understand you here.

You said:

I am able to have Jenkins notify STASH via a checkmark the status of a build. The only thing, I can’t get working with the ‘Stash Webhook’ plugin is to build (trigger) a job on a pull request. 

However, does what I posted answer your question? Meaning: I understood your initial question was that you wanted to see the status of the Pull Request build on Stash.

As I explained above, you have to get your Jenkins to build the "source branch" of the Pull Request and notify Stash about its status. That's what you mean by "building the Pull Request".

I don't know how you can make Jenkins build the "source branch" of the Pull Request. You can look at the references I gave you to figure it out.


Hi Ashish,

you can check out my blog post ( which has a detailed description how to trigger Jenkins jobs on various pull request events and automatically merges the source branch of the pull request with the target branch of the pull request.

Best Regards


Thanks for this Christian, it was super helpful and i've now extended the process you gave to put static code comments on a pull request


It usses another of Thomas Bjerre plugins.

Check out ( for details

@Christian Galsterer your blog is so thorough and damn helpful.. 

I had no issues getting this to work just following your blog after a whole day i spent in troubleshooting the plugin for my use case.. 

the little trick to use /pr made my day !!! 

Hi Christian,


Thanks so much for the blog post. Just one last thing...what steps should I omit (from your blog post) if I only want to execute the Jenkins job based on the pull request but NOT merge my changes after the build passes? I still want to control when to merge my changes. I only want Jenkins to perform a build based on a pull request 'event'.





Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

Bitbucket Server 7.0 is here!

Hello Community, I’m Anton Genkin, a product manager on the Bitbucket Server and Data Center team and am excited to share that Bitbucket Server 7.0 is now available! It's a platform release, one th...

989 views 6 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you