BitBucket Jenkins doesn't automatically build

后端 未结 14 947
予麋鹿
予麋鹿 2020-12-30 21:44

On my Jenkins I configured:

Source Code Management

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

credentials: username/

相关标签:
14条回答
  • 2020-12-30 22:18

    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.

    0 讨论(0)
  • 2020-12-30 22:19
    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.

    0 讨论(0)
  • 2020-12-30 22:21

    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.

    0 讨论(0)
  • 2020-12-30 22:21

    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).

    0 讨论(0)
  • 2020-12-30 22:25

    I second the statements here that say we do not need POLL SCM option with "Build when a change is pushed to BitBucket" but we need to make sure that webhook created in Bit bucket is correct.

    Settings I used in BitBucket are: Repository Settings -> Webhooks

     1. Title: <Anything>
     2. URL: https://jenkins_server_ip:8443/bitbucket-hook/
     3. Status: (Tick) Active
     4. SSL / TLS: (Tick) Skip certificate verification (Not ticking this was causing no auto-trigger in my case)
     5. Request History: (Untick) Enable request history collection
     6. Triggers : (Tick) Repository push
    

    Hope this helps!

    0 讨论(0)
  • 2020-12-30 22:26

    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
    0 讨论(0)
提交回复
热议问题