Reputation: 31570
I currently have this:
multibranchPipelineJob("myjob") {
branchSources {
branchSource {
source {
bitbucket {
credentialsId('bitbucket-login-user-pass')
repoOwner('myteam')
repository('myrepo')
autoRegisterHook(true)
}
}
}
}
}
But I also need to add the following settings:
How do I add these settings in the config? Are they "traits" where do I go to see what traits I have available?
Upvotes: 4
Views: 4936
Reputation: 7703
I think @prumand provide the best way to investigate the job dsl, below I'm adding example single repo multibranch pipeline from my side:
multibranchPipelineJob('/myjob') {
factory {
workflowBranchProjectFactory {
scriptPath('Jenkinsfile')
}
}
branchSources {
branchSource {
source {
bitbucket {
id('123456789')
serverUrl('https://bitbucket.org')
credentialsId('bitbucket-access-id')
repoOwner('myGroupOrUser')
repository('myRepository')
autoRegisterHook(true) // or not
traits {
bitbucketBranchDiscovery {
strategyId(3) // 1 - exclude branches that are also filled as PRs, 3 - all branches
}
bitbucketPullRequestDiscovery {
strategyId(1) // 1 - merging PR with the current target branch revision, 2 - current pull request revision
}
}
}
}
}
}
orphanedItemStrategy {
discardOldItems {
numToKeep(3)
}
}
triggers {
periodicFolderTrigger {
interval('86400000') // 1 day
}
}
}
Upvotes: 0
Reputation: 190
You can have a look at the jobDSL-API-Viewer of your jenkins-instance. This will show you all available jodDSL functions for your instance (jobDSL for installed plugins):
https://your.jenkins.url/plugin/job-dsl/api-viewer/index.html
Upvotes: 9
Reputation: 306
multibranchPipelineJob('example'){
branchSources{
branchSource{
source{
bitbucket{
repoOwner(project)
repository(name)
credentialsId('git_user')
traits {
bitbucketBranchDiscovery{
strategyId(1)
}
}
}
}
}
}
Where traits are defined in the DSL documentation and the strategyId correct value I found in the bitbucket plugin source code.
Must be easy to discover the rest of the options from here.
Upvotes: 2
Reputation: 2257
this is what I use (bitbucket wrapped with organizationFolder
):
organizationFolder('example') {
description('This contains branch source jobs for Bitbucket')
displayName('The Organization Folder')
triggers {
periodic(86400)
}
organizations {
bitbucket {
repoOwner('myorg')
credentialsId('BITBUCKET_CRED')
autoRegisterHooks(false)
traits {
sourceRegexFilter {
// A Java regular expression to restrict the project names.
regex('.*')
}
}
}
}
properties {
mavenConfigFolderOverrideProperty {
override(true)
settings {
settingsConfigId('DEFAULT_MAVEN_SETTINGS')
}
}
}
// discover Branches (workaround due to JENKINS-46202)
configure { node ->
// node represents <jenkins.branch.OrganizationFolder>
def traits = node / 'navigators' / 'com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMNavigator' / 'traits'
traits << 'com.cloudbees.jenkins.plugins.bitbucket.BranchDiscoveryTrait' {
strategyId(3) // detect all branches
}
}
}
Upvotes: 6