Skip to end of metadata
Go to start of metadata

With this service, you can integrate Bitbucket with Jenkins, an extendable open source continuous integration server. If you are having trouble with the service, see Troubleshoot Bitbucket services. For help understanding Jenkins' security options and their implications to triggering remote builds, please review the Jenkins documentation

Setting Up the service

 You must have administrative access on a repository to add this service.

  1. Go to the repository's settings.
  2. Click Services in the left-hand navigation.
    The Services page appears.
  3. Select the Jenkins service from the services dropdown.
  4. Click Add service.
    A new section appears for the Jenkins service.
  5. Enter the following information:

    Csrf EnabledIf set, the service will work with Jenkins when csrf is enabled on the server. (error)
    Module nameIf set, only commits to the specified module (or directory) will trigger a Jenkins build.apps/Bitbucket(error)
    TokenIf you have token authentication enabled for your builds, insert it here. (error)
    Project NameThe name of the Jenkins job you wish to run builds onbitbucket Selenium Tests(tick)

    The endpoint URL for your Jenkins instance. This can be any standard URL in the format. Basic authentication will be used when providing a username and password in the field.


  6. Press Save.


  1. I am also having trouble with this feature.  There is precious little out there out google to help and it seems it may be due to a change in jenkins API.

    Could the generated URL be presented under the form in the UI?  That would be tremendous help tracking this bug down.

  2. Anonymous

    Dumb question: is the "Endpoint" supposed to be a publicly accessible url for your Jenkins server?  It seems so. Do people really expose their Jenkins build servers and all their source code to the public?  If it's not public, then I have no idea what is supposed to go in that field.

    Any Bitbucket guys viewing these forums?

    1. Yes, in order to use the Jenkins service, you will need to make your server publicly available. You can configure Jenkins to require Bitbucket access your server via basic auth. Then you can set the endpoint to:

      <username>:<api token>@<jenkins server host>
  3. Anonymous

    Hi, it would be really great to be able to test this feature without performing a commit. Github has a "test" button and it certainly makes things easier when trying to figure out why it isn't working.

    Also is it possible to document how bitbucket interacts with Jenkins based on the parameters so that it can be seted with curl? For some reason our commits stopped being triggered in our Jenkins instance a few weeks ago and I have no idea why it isn't working.

  4. Anonymous


    Projektname: MyProjekt

    Token: mytoken

    The token is set in the project configuration, the api token is taken from the user configuration.

    1. Anonymous

      This is the most clear example and, in my opinion, should be appended to the documentation.



  5. Is there a way to only trigger a build when a commit is done in a specified branch?

    1. Anonymous

      I'm looking for the same thing.  I don't want a build pushed out for every time something is committed to a feature branch.  Only my main branch should cause a new build.

      1. Anonymous

        I found a solution.  It is documented here:

        In a nutshell, you have to use the bitbucket POST HOOK, not a JENKINS HOOK, and you post to:

        http://yourserver/jenkins/git/notifyCommit?url=<URL of the Git repository>


        Also, you have to have your modify your Jenkins job to use SCM polling, but leave the schedule part blank.  

        That is critical.  You must check the SCM polling, but leave the cron entry blank.

    2. Anonymous

      If we could specify that the URL should go to <jenkins url>/polling instead of <jenkins url>/build then Jenkins can check if there's new changes to that branch and build if there are.

      1. Anonymous

        I've built an application that lets you easily do this.  It's a lightweight node app that receives post-receive hooks from bitbucket, and forwards it to jenkins based on the branch that was committed to.

        Check it out here (I need to improve the documentation):

        1. Anonymous

          We have the same kind of setup running through PHP:

          1. Anonymous

            WOW GREAT FIXZ!!!  (Thanks for the workaround.)

  6. Anonymous

    I entered Project name and Endpoint in public Jenkins. When i commit the changed, should it start automaticly build? it didnt start .


    1. Please send an email to to get assistance with this.

    2. Anonymous

      I had a similar issue, it ended up being a firewall issue, that the port wasn't open on the server. Unfortunately, bitbucket does not let you know if it successfully hit the url or not - it would be great if a log was visible for these posts, or even the server response was visible.

    3. I had a similar issue, it ended up being a firewall issue, that the port wasn't open on the server. Unfortunately, bitbucket does not let you know if it successfully hit the url or not - it would be great if a log was visible for these posts, or even the server response was visible.


  7. Hi,

    I have tried to get the Bitbucket Jenkins service integration working by following the steps outlined above.

    My Jenkins server has security enabled and hence I have used a token for my job as outlined @

    However, this doesn't trigger my remote job. When I try to hit the url from the command line using curl : i.e curl http://<user>:<pass>@<server_name>/jenkins/job/<project_name>/build?token=<my_token> then the remote job gets triggered.

    Additionally I also try to do a Bitbucket POST using the URL outlined in curl but even this doesn't trigger the job.

    Help appreciated on this.


    1. Hi Barry,

      Please send an email to our support team is very responsive.



  8. Anonymous

    I gave up trying to support the service because it gives little feedback when things are going wrong. It also doesn't support a secured jenkins nor triggering a branch. Finally it requires more setup on jenkins site (authentication URL).

    A better solution (at least for git users) is to use Jenkins support of push 

    It requires no more specific authentication, no per job specific configuration on the bitbucket side, and works with branches out of the box as it reuses the polling mechanism.


  9. Anonymous

    What worked nicely for me is to leave module name and token empty, and just fill out project name and endpoint with excatly the url format Barry S posted above. Obviously you need to add the appropriate user with password in Jenkins first.

    Thanky Barry (wink)



  10. Anonymous

    Same here.

    Tried every suggestion here but it just wouldn't work! I verified with curl that my endpoint is correct.


  11. Here's what worked for me:

    Module name: Blank

    Token: The token from the build job I want to run

    Project name: The build project name


    Key points: 

    • The usertoken in the URL is the token for the user account, not the password, and not the same token used for the job.
    • The endpoint URL is not the full URL. Bitbucket adds on the /build/jobname?token=token, using the other fields you enter.


  12. Anonymous

    Does this support the buildWithParameters option of Jenkins? My projects on jenkins won't trigger with just using the "build" parameter.

    1. Anonymous

      I documented how to trigger Jenkins Parameterized Jobs here.

      Basically you leave the Project Name field blank and use the following endpoint URL:



  13. Another success here for me.  It took some troubleshooting as there is no feedback from the bitbucket callback that I could find.

    My Jenkins is integrated with Google Apps for logins.  Therefore, your user name has an @ sign in it.  So you need to make sure you urlencode it.

    For example, is ''.


    My example url:

  14. Anonymous

    This is truly worthless if I cant build per branch, sigh.... 

  15. Anonymous

    After few hours I finally found out that in our case option "" must be turned off.

    Hope this might help someone...

  16. Logging would really help here. I don't see anything happening on the Jenkins server side (not even an attempt to call the server). I suspect it's because our server requires SSL and there's some issue with the certificate (perhaps the CA isn't supported).

  17. is it possible to let bitbucket trigger a jenkins job if an branch get a commit? Is that the use for the module field?

    1. Module name is very VERY confusing!

      Is this relating to a particular branch?


      I want one branch to trigger one jenkins job (dev) and other branch to trigger a different job (staging)


      Any idea how to do this?

  18. Anonymous

    Hmm it actually not work with my jenkins instance hostet by cloudbees ... I set a auth token in jenkins and set all necessary attributes in bitbucket but after a push to my repo nothing happens ... has anyone experience with jekins on cloudbees and bitbucket ?

    1. Anonymous

      I am using Jenkins hosted by Cloudbees and I just set this up without any problems (besides the fact that builds will be triggered if someone commits to branch, which makes this hook pretty much useless).

      You have to watch out for 2 things:

      • Anonymous user needs Read access OR use the Build Token Root Plugin
      • You need to add a trailing ampersand to the ENDPOINT and leaving everything else blank!
  19. The service endpoint doesn't seem to support crendetials. I tried to pass them in URL as but don't get it to send me commit notification.

    1. May need to url encode things.  See my previous post on what I had to do.


      Re: Jenkins Service Management

  20. I did, but didn't got it.

    Could you fill a RFE to enter credentials as a dedicated input, and also to provide a test button ?

  21. Is it possible to fire a build without commiting?

    I'm setting this up and it would help for testing purposes.



  22. Anonymous


      I find it really insane / lame that an employee of Atlassian is suggesting we tweet our issue to get attention..  Can you simply bring this crap up to the devs? 


    1. This problem was fixed except in configurations where CSRF is enabled. If that is the case for you, please follow for a resolution.  If that isn't the case for you, see Troubleshooting Bitbucket Services for information on debugging.  If you still have problems, please raise an issue with

      I do mention problems like this directly to dev. Also, they do regularly triage issues. Even so, as you can imagine, often some issues have priority above other issues. I suggested tweets because the devs seem to follow them closely. I guess a tweet is the equivalent of a personal commercial in a long day of coding.  

  23. Hi

    someone knows any way to will trigger only if a tag was created?


  24. I found another solution, with a secured Jenkins using the plugin

    Entering only the following URL as Endpoint allows anonymous (token-based) trigger of jobs

    The trailing ampersand is used to "ignore" the parameters bitbucket appends, /build/jobname?token=token


    I believe this option should be supported natively (that of only entering the jenkins build-url). 

    1. Anonymous

      You sir, need an award.  I've tried so many variations that I almost gave up, until I read your comment.  The trailing ampersand was the trick (and leaving everything as blank).  Thank you.  I wish I read your comment earlier.

    2. Anonymous

      This worked for me as well, perfect!

  25. Anonymous

    Does this work for Jenkins not running on port 80? As I am sure my config is correct and its still not working.

    1. Please file a support ticket for this.  

  26. What's the difference between a link and a hook?

    1. A hook is a  place in a software program that allows an external person or program to react to or tap into a program. The hook in this case is more like an event hook which allows Jenkins to respond to a POST event from Bitbucket.

  27. Anonymous

    I previously had a working jenkins hook but for some reason it stopped working. But I got the POST hook to work instead:


  28. Is there a way to setup hooks to push to amazon's SQS or SNS services like there is for github?

  29. Anonymous

    I created, that make it simpler to setup bitbucket/jenkins integration

    1. I looked at this today and I can not get it working.  There is no logging and the instructions are not very clear.  Looks like this could be the solution we have been looking for, but at the very least the docs need some flushing out. 

  30. Anyone using pull request hook?

    How come simple hook is written so bad?

    1. Does your open issue with us, and above also relate to the Jenkins hook? We're looking into the issue. If there is an additional issue specific to the Jenkins hook, please note it here.

      1. It has relation only to pull request hook.

        Simply explained, I dont want hook to be triggered if I post a comment on pul request.

        I know there is checkbox, and I unckeck it, but still when I comment on a pullrequest hook is triggered and our Jenkins builds it again, posts build result as a comment and you get a loop.

        1. Can we move this conversation back into support and/or to the correct page at Pull Request POST hook management? We have an ongoing support ticket with you where we are still working to validate and test this issue.

  31. I spent hours trying to get this to work with a completely standard setup to no avail.  I could successfully trigger a Jenkins build from a browser/rest client (e.g. Postman) by sending a GET to http://<jenkins server url>:8080/job/<project name>/build?token=<token name> (which is the URL Jenkins says to use).  But this hook apparently can't do that.

    Finally settled with letting Jenkins poll BitBucket.

    1. It's been working for us.  It took a bit of troubleshooting.  I used a proxy like Runscope provides for free so you can see what's being sent.


      It's likely something simple, but the lack of visibility is what makes it hard to troubleshoot.  In our case the fact that we use google apps for auth on jenkins, so the user name is a full email ( so we needed to url escape things properly.


      Good luck

  32. If you want to build conditionally, based on commits to a specific branch avoid using this hook

    Instead, setup a "POST" hook to:<your_account>/<your_repo>.git

    On your Jenkins job, just set a trigger to "Poll SCM" but with no schedule.  When commits occur to the repo, this hook will fire every time, and Jenkins will check to see if there are new commits (in the branch you designate) to build.  You can manage what jobs build based on commits to certain branches or directory paths in Jenkins itself.

    1. You have saved me a lot of pain. Thank you!

  33. Is there a way to only fire this webhook if master changes? I make changes to a remote branch and it triggers a build with no changes.  This seems like a feature that should be supported, I know github does.  Please advise.