configure {
it / sources / 'data' / 'jenkins.branch.BranchSource' << {
strategy(class: 'jenkins.branch.DefaultBranchPropertyStrategy') {
properties(class: 'java.util.Arrays$ArrayList') {
a(class: 'jenkins.branch.BranchProperty-array') {
if (comment == "\\[merge\\]") {
'jenkins.branch.NoTriggerBranchProperty'()
}
'com.adobe.jenkins.github__pr__comment__build.TriggerPRCommentBranchProperty' {
commentBody(comment)
}
}
}
}
}
configure {
def traitBlock = it / 'sources' / 'data' / 'jenkins.branch.BranchSource' / 'source' / 'traits'
traitBlock << 'jenkins.plugins.git.traits.CloneOptionTrait' {
extension(class: 'hudson.plugins.git.extensions.impl.CloneOption') {
shallow(false)
noTag(false)
reference()
depth(0)
honorRefspec(false)
}
}
def createDeploymentJob(jobName, repoUrl) {
pipelineJob(jobName) {
definition {
cpsScm {
scm {
git {
remote {
url(repoUrl)
}
branches('master')
extensions {
cleanBeforeCheckout()
}
}
}
scriptPath("jobs/deploy.groovy")
}
}
}
}
createDeploymentJob(deployName, repoUrl)
queue(deployName)
branchSources {
github {
apiUri(GITHUB_API_URI)
scanCredentialsId("37477e0c-2ab6-46fe-a83b-64b1add4777d")
checkoutCredentialsId("37477e0c-2ab6-46fe-a83b-64b1add4777d")
repoOwner(GITHUB_ORGANIZATION_NAME)
repository(repositoryName)
buildForkPRHead(true)
buildForkPRMerge(false)
buildOriginBranch(false)
buildOriginBranchWithPR(false)
buildOriginPRHead(true)
buildOriginPRMerge(false)
}
}
Method 1:
configure {
// my Jenkinsfile doesn't exist in the chef Cookbooks for 900 repositories...
// how can we set a seperate git repo for shared scripts? we don't want to use submodules
it / factory(class: 'org.jenkinsci.plugins.workflow.multibranch.WorkflowBranchProjectFactory') {
owner(class: 'org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject', reference: '../..')
scriptPath("jenkinsfile")
}
}
Method 2:
factory {
workflowBranchProjectFactory {
// Relative location within the checkout of your Pipeline script.
scriptPath('jenkinsfile')
}
}
configure {
def traitBlock = it / 'sources' / 'data' / 'jenkins.branch.BranchSource' / 'source' / 'traits'
traitBlock << 'jenkins.plugins.git.traits.BranchDiscoveryTrait' {}
}
This might be useful for advanceed properties? https://github.com/sumeetraheja/seed-jobs/blob/5698c6f1a3d66586d3454355126bc84a43fcfb64/jobs/checkout/checkout_backend_api_tests_job.groovy
branchSources {
configure { node ->
node / sources(class: 'jenkins.branch.MultiBranchProject$BranchSourceList') / data / 'jenkins.branch.BranchSource' / source(class: 'jenkins.plugins.git.GitSCMSource') {
remote 'ssh://[email protected]:2222/checkout/checkout-api-tests.git'
credentialsId 'jenkins-ci'
includes '*'
excludes ''
ignoreOnPushNotifications 'false'
id ''
traits {
'jenkins.plugins.git.traits.BranchDiscoveryTrait'()
'jenkins.plugins.git.traits.CloneOptionTrait' () {
extension(class: 'hudson.plugins.git.extensions.impl.CloneOption') {
shallow 'false'
noTags 'false'
reference ''
depth '0'
honorRefspec 'false'
}
}
}
}
}
}