BitBucket Jenkins doesn't automatically build

2019-02-07 23:47发布

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.

10条回答
一夜七次
2楼-- · 2019-02-08 00:15

I'm doing the same but without the Bitbucket Plugin in my Jenkins.

I'm using the Jenkins Plugin in my Bitbucket. I've configured the webhook on each repository and pointing with the simply Jenkins URL. Then, into every job that I need, just leave checked the "Poll SCM" with/without schedule (is not required).

With that is working really well and I avoid another plugin installation in my Jenkins.

查看更多
再贱就再见
3楼-- · 2019-02-08 00:16

Did you mark the checkbox where it says: Poll SCM? Also make sure that you schedule a short time to detect the changes in the repository as soon as possible.

Maybe your problem is that you schedule for a long time and after your push Jenkins wait some time to detect the changes.

查看更多
Deceive 欺骗
4楼-- · 2019-02-08 00:17

Had the same issue on Jenkins 2.138.1 with Bitbucket plugin and the problem was that I had to enable "Source Code Management" -> git, otherwise it won't do anything although the webhook appeared on Jenkins's log (/var/log/jenkins/jenkins.log).

查看更多
forever°为你锁心
5楼-- · 2019-02-08 00:22

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.

查看更多
来,给爷笑一个
6楼-- · 2019-02-08 00:31

As @Adrian mentioned, you still need to select "Poll SCM". It's a little unintuitive, but when the BitBucket webhook sends a request to Jenkins, Jenkins will poll for changes on all jobs that reference the BitBucket repo where the change was made. You can set a long time interval for the poll, e.g. @monthly, as you don't need Jenkins' scheduling to trigger polling; the web hook will take care of that as soon as a change is made.

查看更多
Bombasti
7楼-- · 2019-02-08 00:31
  1. Go to your projects page on https://bitbucket.org
  2. Settings -> Webhook -> Click on "Add webhook"
  3. Add https://yourjenkinsserver.com/bitbucket-hook/
  4. Push again

This needs your Jenkisserver to have the bitbucket plugin. Check it by going to https://yourjenkinsserver.com/bitbucket-hook/ - it will crash, but you will know you installed it.

查看更多
登录 后发表回答