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

Webhooks not registered to Bitbucket server when multi branch pipeline job created with Job DSL

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • Jenkins: 2.73.3
      Bitbucket server 5.6.2
      Bitbucket Branch Source Plugin: 2.2.10

      I am observing that when a multi branch pipeline job is created (or recreated) by a Jenkins a Job DSL script, post webhook is not automatically registered to Bitbucket server. 

      When I configure and save that same job from the Jenkins UI, the post webhook gets registered. Expecting that Job DSL job create/recreate should also register webhooks to Bitbucket server.

      Actual config.xml for the job:

      <?xml version="1.0" encoding="UTF-8"?><org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject>
      <actions/>
      <description>Do not change this job manually! This job is managed by job DSL.</description>
      <properties/>
      <icon class="com.cloudbees.hudson.plugins.folder.icons.StockFolderIcon"/>
      <views>
      <hudson.model.AllView>
      <owner class="org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject" reference="../../.."/>
      <name>All</name>
      <filterExecutors>false</filterExecutors>
      <filterQueue>false</filterQueue>
      <properties class="hudson.model.View$PropertyList"/>
      </hudson.model.AllView>
      </views>
      <viewsTabBar class="hudson.views.DefaultViewsTabBar"/>
      <primaryView>All</primaryView>
      <healthMetrics>
      <com.cloudbees.hudson.plugins.folder.health.WorstChildHealthMetric/>
      </healthMetrics>
      <triggers>
      <com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger>
      <spec>* * * * *</spec>
      <interval>86400000</interval>
      </com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger>
      </triggers>
      <sources class="jenkins.branch.MultiBranchProject$BranchSourceList">
      <data>
      <jenkins.branch.BranchSource>
      <source class="com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource">
      <id>predifined-id</id>
      <serverUrl>https://git.example.com</serverUrl>
      <credentialsId>credentialIdWithBasicAuthAccess</credentialsId>
      <repoOwner>project</repoOwner>
      <repository>repo</repository>
      <traits>
      <com.cloudbees.jenkins.plugins.bitbucket.BranchDiscoveryTrait>
      <strategyId>3</strategyId>
      </com.cloudbees.jenkins.plugins.bitbucket.BranchDiscoveryTrait>
      <com.cloudbees.jenkins.plugins.bitbucket.SSHCheckoutTrait>
      <credentialsId>credentialIdWithReadAccess</credentialsId>
      </com.cloudbees.jenkins.plugins.bitbucket.SSHCheckoutTrait>
      <jenkins.scm.impl.trait.WildcardSCMHeadFilterTrait>
      <includes>develop feature/* bugfix/*</includes>
      <excludes/>
      </jenkins.scm.impl.trait.WildcardSCMHeadFilterTrait>
      <com.cloudbees.jenkins.plugins.bitbucket.WebhookRegistrationTrait>
      <mode>ITEM</mode>
      </com.cloudbees.jenkins.plugins.bitbucket.WebhookRegistrationTrait>
      </traits>
      </source>
      </jenkins.branch.BranchSource>
      </data>
      <owner class="org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject" reference="../.."/>
      </sources>
      <factory class="org.jenkinsci.plugins.workflow.multibranch.WorkflowBranchProjectFactory">
      <owner class="org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject" reference="../.."/>
      </factory>
      <orphanedItemStrategy class="com.cloudbees.hudson.plugins.folder.computed.DefaultOrphanedItemStrategy">
      <pruneDeadBranches>true</pruneDeadBranches>
      <daysToKeep>1</daysToKeep>
      <numToKeep>20</numToKeep>
      </orphanedItemStrategy>
      </org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject>
      

          [JENKINS-49653] Webhooks not registered to Bitbucket server when multi branch pipeline job created with Job DSL

          Anssi Wilkko added a comment -

          Tested with another Jenkins master instance and webhooks seem to be registered successfully with Job DSL as well:

          Feb 20, 2018 3:32:51 PM javaposse.jobdsl.plugin.JenkinsJobManagement createOrUpdateConfig
          INFO: createOrUpdateConfig for project/repo
          Feb 20, 2018 3:32:51 PM com.cloudbees.jenkins.plugins.bitbucket.hooks.WebhookAutoRegisterListener registerHooks
          INFO: Registering hook for project/repo
          

           Sorry for the noise.

          Anssi Wilkko added a comment - Tested with another Jenkins master instance and webhooks seem to be registered successfully with Job DSL as well: Feb 20, 2018 3:32:51 PM javaposse.jobdsl.plugin.JenkinsJobManagement createOrUpdateConfig INFO: createOrUpdateConfig for project/repo Feb 20, 2018 3:32:51 PM com.cloudbees.jenkins.plugins.bitbucket.hooks.WebhookAutoRegisterListener registerHooks INFO: Registering hook for project/repo  Sorry for the noise.

          Anssi Wilkko added a comment -

          Re-opening as there seems to be some inconsistency. Newly created jobs register webhooks just fine. If the hook is removed or hook management is added to an existing job, webhook doesn't get automatically registered.

          Anssi Wilkko added a comment - Re-opening as there seems to be some inconsistency. Newly created jobs register webhooks just fine. If the hook is removed or hook management is added to an existing job, webhook doesn't get automatically registered.

          red der added a comment -

          What does your job dsl config look like? how are you setting WebhookRegistrationTrait there?

          red der added a comment - What does your job dsl config look like? how are you setting WebhookRegistrationTrait there?

          Nikolas Falco added a comment -

          Is this issue still present in latest version?

          Nikolas Falco added a comment - Is this issue still present in latest version?

            nfalco Nikolas Falco
            anssiw Anssi Wilkko
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: