Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Jenkins groovy configuration
def projects = [:];
projects['first-repo'] = [
name: 'First multibranch pipeline',
repo: 'repo-first'
]
projects['second-repo'] = [
name: 'Second multibranch pipeline',
repo: 'repo-second'
]
projects.each { id, project ->
multibranchPipelineJob(id) {
displayName(project.name)
description("Do not change this configuration manually!")
branchSources {
branchSource {
source {
bitbucket {
serverUrl("https://url-of-the-server")
repoOwner('NAME-OF-OWNER')
repository(project.repo)
credentialsId('LOOOOONG-ID-ID-ID-ID')
}
}
}
// check every minute for scm changes as well as new / deleted branches
triggers {
periodic(1)
}
// don't keep build jobs for deleted branches
orphanedItemStrategy {
discardOldItems {
numToKeep(-1)
}
}
}
configure {
def traits = it / sources / data / 'jenkins.branch.BranchSource' / source / traits
traits << 'com.cloudbees.jenkins.plugins.bitbucket.TagDiscoveryTrait' {
strategyId(3)
}
traits << 'jenkins.branch.buildstrategies.basic.TagBuildStrategyImpl' { // <<<<< this doesn't work
strategyId(1)
}
it / factory(class: 'org.jenkinsci.plugins.workflow.multibranch.WorkflowBranchProjectFactory') {
owner(class: 'org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject', reference: '../..')
scriptPath('Jenkinsfile')
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment