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:<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>