Reputation: 151
Have a DSL job to create multibranch pipeline jobs in jenkins, running Jenkins 2.107.1
with plugins: 'Branch API Plugin' 2.0.18
, 'Bitbucket Branch Source Plugin' 2.2.10
.
I'm unable to find a proper configuration function to enable property to "Suppress automatic SCM triggering", please help.
Here is my job that works but its just triggers the build as soon as it scans for branch:
multibranchPipelineJob("job") {
configure {
it / sources / data / 'jenkins.branch.BranchSource' / source(class: 'com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource') {
credentialsId('..')
id("..")
checkoutCredentialsId("..")
repoOwner("owner")
repository("my-repo")
includes()
excludes("PR-*")
}
}
}
Upvotes: 7
Views: 5112
Reputation: 151
This is how it works now... with the help of the following source code:
https://github.com/jenkinsci/bitbucket-branch-source-plugin
multibranchPipelineJob("job") {
branchSources {
branchSource {
source {
bitbucket {
credentialsId("myid")
repoOwner("iam")
repository("job")
traits {
headWildcardFilter {
includes("branchestoinclude")
excludes("toexclude")
}
}
}
}
strategy {
defaultBranchPropertyStrategy {
props {
// keep only the last 8 builds
buildRetentionBranchProperty {
buildDiscarder {
logRotator {
daysToKeepStr("-1")
numToKeepStr("8")
artifactDaysToKeepStr("-1")
artifactNumToKeepStr("-1")
}
}
}
}
}
}
}
}
// Branch behaviour
configure {
def traits = it / sources / data / 'jenkins.branch.BranchSource' / source / traits
traits << 'com.cloudbees.jenkins.plugins.bitbucket.BranchDiscoveryTrait' {
strategyId(3) // detect all branches -refer the plugin source code for various options
}
}
orphanedItemStrategy {
discardOldItems {
numToKeep(8)
}
}
}
Upvotes: 8