我正在尝试使用jenkins 舵图,它使用Jcasc和JobDSL来进行作业配置。我已经配置了organizationFolder,其中包含bitbucket配置,它遍历我的bitbucket repos并创建multibranchPipeline作业。看起来不错,可以从bitbucket接收webhooks,但不会触发作业。
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我怀疑这是由于未经检查
当更改被推到BitBucket时,multibranchPipeline配置中的“multibranchPipeline Build”标志。

问题:哪个JobDSL选项支持“在将更改推送到BitBucket时生成”标志?
我的配置是基于这个例子的,如下所示
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:通过Web配置任何东西都不是一种选择,一切都必须作为代码来管理。
发布于 2022-03-31 16:10:01
允许您控制来自分支索引的SCM提交触发器。
organizationFolder(...) {
...
properties {
noTriggerOrganizationFolderProperty {
// automatically trigger builds for branches matching this regex at index time
branches('PR-\\d+')
}
}

https://stackoverflow.com/questions/69813779
复制相似问题