Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-38447

Bitbucket hooks don't work for Pipeline jobs

    Details

    • Similar Issues:

      Description

      I’ve created a Jenkins Pipeline and now I want to run it automatically once Bitbucket receives a new push to master. Problem is that the Bitbucket webhook works fine for a regular freestyle build, but not for a Pipeline job with a Pipeline script from SCM.

      The logs in Bitbucket show that the request succeeded (returns http 200), but in Jenkins I don’t see anything happen, also not in the bitbucket hook log. The Bitbucket hook log in jenkins says ‘Polling has not run yet.’ for a pipeline job, no matter how often scm requests were made. For a freestyle job the hooks work instantly, so it seems to be a problem with the particular Jenkins job type.

        Attachments

          Issue Links

            Activity

            Hide
            mirceaalbu Mircea-Andrei Albu added a comment -

            For me, the trigger works fine for a multi-branch pipeline, but it doesn't work for single(normal) pipeline.

            Show
            mirceaalbu Mircea-Andrei Albu added a comment - For me, the trigger works fine for a multi-branch pipeline, but it doesn't work for single(normal) pipeline.
            Hide
            sc_rsc Stefan Cordes added a comment -

            Cesar Tron-Lozai :
            With

            			pipelineTriggers([
            				// build at least build onetime a month
            				// MINUTE	HOUR	DOM	MONTH	DOW
            				// see https://jenkins.io/doc/book/pipeline/syntax/#triggers
            				// # Build at least once a month
            				cron('H H(10-17) H * 1-5')
            		        // for test every 5 minutes
            				//        cron('*/5 * * * *')
            				,
            				// poll scm nightly to ensure no push events were lost.
            				pollSCM('H H(3-7) * * *')
            				,
            				// https://issues.jenkins-ci.org/browse/JENKINS-38447?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel&showAll=true
            				[$class: 'com.cloudbees.jenkins.plugins.BitBucketTrigger']
            				,
            				snapshotDependencies()
            			])
            

            it worked for me when using $JENKINS_HOME/bitbucket-hook/ when

            • https bitbucket URL and not ssh
            • git and not bitbucket-source
              in "Project Repository"

            (reason: see com.cloudbees.jenkins.plugins.BitbucketJobProbe.match(..))

            Show
            sc_rsc Stefan Cordes added a comment - Cesar Tron-Lozai : With pipelineTriggers([ // build at least build onetime a month // MINUTE HOUR DOM MONTH DOW // see https://jenkins.io/doc/book/pipeline/syntax/#triggers // # Build at least once a month cron('H H(10-17) H * 1-5') // for test every 5 minutes // cron('*/5 * * * *') , // poll scm nightly to ensure no push events were lost. pollSCM('H H(3-7) * * *') , // https://issues.jenkins-ci.org/browse/JENKINS-38447?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel&showAll=true [$class: 'com.cloudbees.jenkins.plugins.BitBucketTrigger'] , snapshotDependencies() ]) it worked for me when using $JENKINS_HOME/bitbucket-hook/ when https bitbucket URL and not ssh git and not bitbucket-source in "Project Repository" (reason: see com.cloudbees.jenkins.plugins.BitbucketJobProbe.match(..))
            Hide
            sc_rsc Stefan Cordes added a comment -

            The above workaround is valid for existing branches in a multibranch project.

            For new branches the Bitbucket trigger still fails.

            For that reason I investigated a little bit and found out that the Bitbucket trigger is just checking for instanceof BitBucketTrigger

            but the MultiBranch Pipeline is not a BitBucketTrigger but a SCMSourceOwner

            So I modified the BitbucketJobProbe to consider jenkins.scm.api.SCMSourceOwner:

            https://github.com/jenkinsci/bitbucket-plugin/pull/68

            (With that pull request the above "existing branch" Workaround: [$class: 'com.cloudbees.jenkins.plugins.BitBucketTrigger'] (or ,bitbucketPush()) can be removed again)

            Can someone merge it, please?

            Show
            sc_rsc Stefan Cordes added a comment - The above workaround is valid for existing branches in a multibranch project. For new branches the Bitbucket trigger still fails. For that reason I investigated a little bit and found out that the Bitbucket trigger is just checking for  instanceof BitBucketTrigger but the MultiBranch Pipeline is not a BitBucketTrigger but a  SCMSourceOwner So I modified the BitbucketJobProbe to consider jenkins.scm.api.SCMSourceOwner: https://github.com/jenkinsci/bitbucket-plugin/pull/68 (With that pull request the above "existing branch" Workaround: [$class: 'com.cloudbees.jenkins.plugins.BitBucketTrigger'] (or ,bitbucketPush() ) can be removed again) Can someone merge it, please?
            Hide
            miike Michael Kaiser added a comment -

            To work around this problem you can also just use this plugin: 

            Multibranch Scan Webhook Trigger
            https://plugins.jenkins.io/multibranch-scan-webhook-trigger/

             

            Show
            miike Michael Kaiser added a comment - To work around this problem you can also just use this plugin:  Multibranch Scan Webhook Trigger https://plugins.jenkins.io/multibranch-scan-webhook-trigger/  
            Hide
            sc_rsc Stefan Cordes added a comment -

            Additional multibranch-scan-webhook-trigger will require a second webhook to be configured in each Repository (and [at least on our company] whitelisted in the network infrastructure).
            When finally fixed the second webhook needs to be removed from all Bitbucket repos again.

            So the more ease solution is to fix it with https://github.com/jenkinsci/bitbucket-plugin/pull/68

            Show
            sc_rsc Stefan Cordes added a comment - Additional multibranch-scan-webhook-trigger will require a second webhook to be configured in each Repository (and [at least on our company]  whitelisted in the network infrastructure). When finally fixed the second webhook needs to be removed from all Bitbucket repos again. So the more ease solution is to fix it with  https://github.com/jenkinsci/bitbucket-plugin/pull/68

              People

              • Assignee:
                Unassigned
                Reporter:
                jorrith Jorrith Schaap
              • Votes:
                43 Vote for this issue
                Watchers:
                52 Start watching this issue

                Dates

                • Created:
                  Updated: