Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BitBucket Jenkins doesn't automatically build

On my Jenkins I configured:

Source Code Management

Git repository: https://bitbucket.org/username/project.git

credentials: username/password

Builder Triggers

Build when a change is pushed to BitBucket

On my BitBucket Webhooks:

http://Jenkins.URL:8080/bitbucket-hook

I tried pushing a small change to a .txt file, but the Jenken doesn't build automatically. If I manually click "build now", it shows success.

What could be the problem?

In the bitbucket repository, the project is simple. I just have a text file to test. I think as long as I made any change to the text file, it should trigger a Jenkins build.

Edit:

In the System Log of Jenkins, it shows "Polling has not run yet.". But in Bitbucket Webhook request log, I can see all the requests.

like image 462
user697911 Avatar asked Jul 03 '15 08:07

user697911


People also ask

How do I trigger a build automatically in Jenkins?

Follow the steps as mentioned below to trigger a Jenkins job automatically based on GitHub's webhook configurations: Step 1: Go to the Configuration page of the respective job and under the build trigger section, check the "GitHub hook trigger for GITScm polling" checkbox and click on the Save button.


2 Answers

You don't need to enable Polling SCM..

You have to ensure that your Webhook (Settings->Webhooks) is pointing to your Jenkins bitbucket-hook like the following: "https://ci.yourorg.com/bitbucket-hook/".

Notice that last "/", without it, the build will not be triggered.

It's an annoying thing, as you will get a 200 status code from Jenkins when sending requests, with or without it.

like image 175
Haukur Kristinsson Avatar answered Sep 19 '22 07:09

Haukur Kristinsson


After some struggling with the BitBucket plugin, I have managed to get it working. Below is the summary of things I found are necessary for builds to be triggered, but are not obvious from plugin's documentation:

  1. Make sure your webhook has repository push trigger enabled. I thought pull request created / updated would suffice (building on PR is what I wanted) but the plugin reacts only to push.
  2. Set your repository URL (in Git plugin) to https://bitbucket.org/REPOSITORY_OWNER/REPOSITORY_NAME. Plugin will not match it if it's the SSH url.
  3. You do need the SCM polling enabled. The plugin itself does not pull the changes. You can leave the schedule field empty, so repository is polled only when the plugin triggers it.

I hope this helps. If the build is still not triggered for you, try enabling logs for the following classes:

  • com.cloudbees.jenkins.plugins.BitbucketHookReceiver
  • com.cloudbees.jenkins.plugins.BitBucketTrigger
  • com.cloudbees.jenkins.plugins.BitbucketJobProbe
  • com.cloudbees.jenkins.plugins.BitbucketPayloadProcessor
  • com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource
like image 37
Jezor Avatar answered Sep 23 '22 07:09

Jezor