How do I get Jenkins to build on push to a BitBucket git repository?

I have a git repository hosted on BitBucket, and have set up SSH authentication between the repository and my Jenkins server. I can build on Jenkins manually, but cannot get the Jenkins service on BitBucket to trigger builds.

Jenkins configuration:  
- Project Name: [my_jenkins_job]  
- Build Triggers:  
--Trigger Builds Remotely:  
---Token: [token]

BitBucket configuration:  
- Endpoint: http://[my_jenkins_address]/job/[my_jenkins_job]/build (I've also tried build?token=[token])  
- Project Name: [my_jenkins_job]  
- Module Name: [blank]  
- Token: [token]

Visiting http://{my_jenkins_address}/job/{my_jenkins_job}/build?token={token} kicks off a build properly.

Why doesn’t pushing a change to BitBucket cause Jenkins to initiate a build?

  • Cannot generate coverage report using lcov
  • Conditional OR for multiple Jenkins parameters
  • Building Boost dynamically linkable gives linking error?
  • how to modify/add/delete tool installations on a Jenkins slave using Groovy?
  • Jenkins Git connection
  • Jenkins - Unable to git clone from slave node. SSH keys
  • Can't authenticate with GitHub
  • Running QUnit tests with Jenkins and Apache Ant?
  • 6 Solutions collect form web for “How do I get Jenkins to build on push to a BitBucket git repository?”

    I have our Jenkins instance set up to poll the repository every minute. Is that not frequent enough for your needs?

    Our Jenkins configuration:

    Build Triggers > Poll SCM = Checked

    Build Triggers > Poll SCM > Schedule =

    # every 1 minute
    */1 * * * *

    Due to the Jenkins Hook of Bitbucket is not working at all for me and I have different Jenkins projects for different branches I had come to this solution:

    • Install Bitbucket Plugin at your Jenkins
    • Add a normal Post as Hook to your Bitbucket repository (Settings -> Hooks) and use following url:


    and if you have setup authentication on jenkins then URL must be like


    • Configure your Jenkins project as follows:
    • under build trigger enable Build when a change is pushed to BitBucket
    • under Source Code Management select GIT; enter your credentials and define Branches to build (like **feature/*)

    By this way I have three build projects, one for all features, one for develop and one for release branch. Make sure to include the slash (‘/’) on the end of the URL or the hook won’t work.

    And best of it, you don’t have to ad new hooks for new Jenkins projects.

    You can actually get this to work in Jenkins with the Bitbucket service, but it took some playing around to get it working.

    If you use authentication, you can grab an API token from one of the users that can create builds. I created a separate account just for Bitbucket. You’ll need at least Jenkins 1.426 to use the API token. You can then use HTTP authentication with the API token as your password for the Bitbucket service.

    This is how mine is set up:

    Endpoint: http://[bitbucket]:[APITOKEN]@[

    Project Name: [NameOfMyJenkinsProject]

    Module Name: [empty]

    Token: [Token found in Jenkins project settings]

    After I set it up like this, I was able to use the token as well as authentication to enable push-triggered builds from Bitbucket.

    The token stuff is useless if you use authentication in Jenkins.

    use the Git plugin, and use a POST hook with http[s]://[/jenkins]/git/notifyCommit? in it. Be sure that polling is on and schedule at some value, or this won’t work.

    Just install the bitbucket plugin and follow the instructions as can be found on the plugins page:

    Configure your BitBucket repository with a POST hook, using URL
    JENKINS_URL/bitbucket-hook (no need for credentials). On each commit,
    all jobs with “Build when a change is pushed to BitBucket” option
    enabled will be triggered.

    See here:

    Using Poll SCM is good, however it has few disadvantages also, it will fetch metadata from you GIT Repository, which anyway is using some percentage of bandwidth from your bitbucket server and Jenkins server.

    It’s better that Bitbucket knows when to trigger Jenkins if any new update arrives.If you are using bitbucket latest versions, there are a plugin name “Stash webhooks for Jenkins” which is now compatible with Bitbucket.

    Within this plugin, you just have to specify the Jenkins URL and the JOB name, this also provides an extra layer of security between Jenkins and Bitbucket.
    enter image description here

    This is the plugin (Stash webhooks for Jenkins which is not called Bitbucket webhooks for Jenkins) which can be downloaded from Atlassian Marketplace.

    enter image description here
    Above is the Add-on settings where you have to specify Jenkins URL and Repo Clone URL. With the trigger, you can also check the connection etc.

    Link for the plugin : Bitbucket webhooks for Jenkins

    How this Plugin works:

    1. Install the Git Plugin in Jenkins. Configure your project to use Git
      for your Source Code Management. You will need to keep the
      Repository URL you use for configuration in Stash. Enable the Poll
      SCM option in the Build Triggers. This is required to remotely
      trigger a build. Since we don’t really need to poll, you can set the
      poll frequency to poll very infrequently. Save your project

      1. Enter the URL for your Jenkins instance and the Repository URL that you configured Jenkins to use. You can use the dropdown to get
        the clone URL for each supported the protocol. Afterwards, feel free to
        change it to match your Jenkins instance.

      2. That’s it!

      With both Jenkins and Stash now configured, if you commit code, a
      build trigger will automatically occur. What happens is the
      post-receive hook fires a GET request to Jenkins, which then tells
      it to poll the repository (why you need to have polling turned on).
      The poll checks to see if there are actually any changes. Since
      there are, it triggers the build!

    Git Baby is a git and github fan, let's start git clone.