Jenkins job dsl for bitbucket branch 源插件文档和完整示例?

red*_*888 3 jenkins jenkins-plugins jenkins-job-dsl

我目前有这个:

multibranchPipelineJob("myjob") {
  branchSources {
    branchSource {
      source {
        bitbucket {
          credentialsId('bitbucket-login-user-pass')
          repoOwner('myteam')
          repository('myrepo')
          autoRegisterHook(true)
        }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

但我还需要添加以下设置: 在此处输入图片说明

如何在配置中添加这些设置?它们是“特质”吗?我该去哪里查看我有哪些特质?

dom*_*omi 6

这就是我使用的(bitbucket 用 包裹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
        }
    }    
}
Run Code Online (Sandbox Code Playgroud)


小智 5

您可以查看 jenkins 实例的 jobDSL-API-Viewer。这将显示您的实例的所有可用 jodDSL 功能(已安装插件的 jobDSL):

https://plugin/job-dsl/api-viewer/index.html