可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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.
回答1:
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.
回答2:
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.
回答3:
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.
回答4:
Using Jenkins 2.53 and Bitbucket plugin 1.1.5, I had to manually trigger the build first to get the webhook to work.
What tipped me off was this line from the documentation:
If the job's SCM (git) detects that the remote repository has changes, THEN
After that the webhook work great.
回答5:
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.
回答6:
You must pay attention to the Branch specifier field and specify the branch that you are pushing to.
Jenkins plugin for Bitbucket will not start a job if no changes are detected. you can add more than one branch to be watched.
as mentioned by the official documentation only If the job's SCM (git) detects that the remote repository has changes THEN it will invoke the build.
So if you leave the branch specifier with its default value */master and you are pushing to a different branch then the job will not be executed.