可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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:
- Go to your projects page on https://bitbucket.org
- Settings -> Webhook -> Click on "Add webhook"
- Add https://yourjenkinsserver.com/bitbucket-hook/
- 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.
回答6:
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.
回答7:
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.
回答8:
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).
回答9:
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:
- 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
.
- 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.
- 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
回答10:
I was struggling with this issue for long, and couldn't find a solution in Jenkins documentation, I found here a solution in Cloudbees support site.
You just need to add these tow webhooks to your bitbucket repo :
https://JENKIN_URL/bitbucket-scmsource-hook/notify
https://JENKIN_URL/bitbucket-hook
And i work for all pipelines even MultiBranch ones.
Hope this helps someone ;)
ADA