Created
July 11, 2018 09:07
-
-
Save sobi3ch/170bfb0abc4b7d91a1f757a9db07decf to your computer and use it in GitHub Desktop.
Jenkins groovy configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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