I am trying to use jenkins helm chart that uses Jcasc and JobDSL for job configuration. I have configured organizationFolder with bitbucket config inside that traverses my bitbucket repos and creates multibranchPipeline jobs. Looks good and receives webhooks from bitbucket but does not trigger jobs.
ue Nov 02 14:49:53 UTC 2021] Received com.cloudbees.jenkins.plugins.bitbucket.hooks.PushHookProcessor$1
UPDATED event from 10.0.0.112 ⇒ http://zzzzzzzzz:8080/bitbucket-scmsource-hook/notify with timestamp Tue Nov 02 14:49:53 UTC 2021
Connecting to https://bitbucket.org using zzzzzzzzzz/******
Repository type: Git
Looking up bddevteam83/infra-system for branches
Checking branch master from zzzzzzzzzzz/zzzzzz-system
'Jenkinsfile' found
Met criteria
Changes detected: master (null → d57b19309533ffd5133f88eb3809d1ad3896bfc8)
Did not schedule build for branch: master
I suspect it happens due to unchecked
"Build when a change is pushed to BitBucket" flag in multibranchPipeline config.
QUESTION: which JobDSL option enables "Build when a change is pushed to BitBucket" flag?
my config is based on this example and looks like this
organizationFolder('bitbucket') {
description("Bitbucket organization folder configured with JCasC")
displayName('bitbucket')
properties {
noTriggerOrganizationFolderProperty {
branches('develop')
}
}
// "Projects"
organizations {
bitbucket {
serverUrl("https://bitbucket.org/")
repoOwner("zzzzzzzzzzz")
credentialsId("bitbucket-http")
// "Traits" ("Behaviours" in the GUI) that are "declarative-compatible"
traits {
webhookRegistrationTrait {
mode('ITEM')
}
submoduleOptionTrait {
extension {
disableSubmodules(false)
recursiveSubmodules(true)
trackingSubmodules(false)
reference(null)
timeout(null)
parentCredentials(true)
}
}
}
}
}
// "Traits" ("Behaviours" in the GUI) that are NOT "declarative-compatible"
// For some 'traits, we need to configure this stuff by hand until JobDSL handles it
// https://issues.jenkins.io/browse/JENKINS-45504
configure { node ->
def traits = node / navigators / 'com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMNavigator' / traits
// Discover branches
traits << 'com.cloudbees.jenkins.plugins.bitbucket.BranchDiscoveryTrait' {
strategyId('1')
// Values
// 1 : Exclude branches that are also filed as PRs
// 2 : Only branches that are also filed as PRs
// 3 : All branches
}
traits << 'com.cloudbees.jenkins.plugins.bitbucket.SSHCheckoutTrait' {
credentialsId('bitbucket-git-ssh-key')
}
// Filter by name (with regular expression)
traits << 'jenkins.scm.impl.trait.RegexSCMSourceFilterTrait' {
regex('.*')
}
// Discover pull requests from origin
traits << 'com.cloudbees.jenkins.plugins.bitbucket.OriginPullRequestDiscoveryTrait' {
strategyId('1')
// Values
// 1 : Merging the pull request with the current target branch revision
// 2 : The current pull request revision
// 3 : Both the current pull request revision and the pull request merged with the current target branch revision
}
// Discover pull requests from forks
traits << 'com.cloudbees.jenkins.plugins.bitbucket.ForkPullRequestDiscoveryTrait' {
strategyId('1')
// Values
// 1 : Merging the pull request with the current target branch revision
// 2 : The current pull request revision
// 3 : Both the current pull request revision and the pull request merged with the current target branch revision
trustID('1')
// Values
// 0 : Everyone
// 1 : Forks in the same account
// 2 : Nobody
}
traits << 'jenkins.scm.impl.trait.RegexSCMHeadFilterTrait' {
regex('(master)|(develop)|(development)|(integration)|(release.*)')
}
}
// "Project Recognizers"
projectFactories {
workflowMultiBranchProjectFactory {
scriptPath 'Jenkinsfile'
}
}
// "Orphaned Item Strategy"
orphanedItemStrategy {
discardOldItems {
daysToKeep(30)
numToKeep(100)
}
}
// "Scan Organization Folder Triggers" : 1 day
// We need to configure this stuff by hand because JobDSL only allow 'periodic(int min)' for now
configure { node ->
node / triggers / 'com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger' {
spec('H H * * *')
interval(86400000)
}
}
//// the below config I added seems to have no effect on "Build when a change is pushed to BitBucket"
configure { node ->
node / triggers / 'com.cloudbees.jenkins.plugins.BitBucketMultibranchTrigger' {
overrideUrl('')
}
}
configure { node ->
node / triggers / 'com.cloudbees.jenkins.plugins.BitBucketTrigger' {
overrideUrl('')
}
}
}
UPD: configuring anything via Web UI is not an option, everything must be managed as code.