Pipeline Multibranch jobs //多分支流水线
Unlike other job types, there is no ‘Trigger’ setting required for a Multibranch job configuration; just create a webhook in GitLab for push
requests which points to the project’s webhook URL. When GitLab POSTs to this URL, it will trigger branch indexing for the Jenkins
project, and Jenkins will handle starting any builds necessary.
If you want to configure some of the trigger options, such as the secret token or CI skip functionality, you can use a properties step. For
example:
//Define your secret project token heredefproject_token =‘abcdefghijklmnopqrstuvwxyz0123456789ABCDEF’//Reference the GitLab connection name from your Jenkins Global configuration (https://JENKINS_URL/configure, GitLab section)properties([
gitLabConnection(‘your-gitlab-connection-name’),
pipelineTriggers([
[
$class: ‘GitLabPushTrigger’,
branchFilterType: ‘All’,
triggerOnPush: true,
triggerOnMergeRequest: false,
triggerOpenMergeRequestOnPush: “never”,
triggerOnNoteRequest: true,
noteRegex: “Jenkins please retry a build”,
skipWorkInProgressMergeRequest: true,
secretToken: project_token,
ciSkip: false,
setBuildDescription: true,
addNoteOnMergeRequest: true,
addCiMessage: true,
addVoteOnMergeRequest: true,
acceptMergeRequestOnSuccess: false,
branchFilterType: “NameBasedFilter”,
includeBranchesSpec: “release/qat”,
excludeBranchesSpec: “”,
]
])
])
Multibranch Pipeline jobs with Job DSL
You can use the Dynamic DSL feature of Job DSL to configure the job trigger. See https://github.com/jenkinsci/gitlab-plugin/blob/master/src/main/java/com/dabsquared/gitlabjenkins/GitLabPushTrigger.java for the methods you can use.
job(‘seed-job’) {
description(’ Job that makes sure a service has a build pipeline available’)
parameters {
//stringParam(‘gitlabSourceRepoURL’, ‘’, ‘the git repository url, e.g. [email protected]:kubernetes/cronjobs/cleanup-jenkins.git’)}
triggers {
gitlab {
//This line assumes you set the API_TOKEN as an env var before starting Jenkins - not necessarily requiredsecretToken(System.getenv(“API_TOKEN”))
triggerOnNoteRequest(false)
}
}
steps {
dsl {
text(newFile(’/usr/share/jenkins/ref/jobdsl/multibranch-pipeline.groovy’).getText(‘UTF-8’))
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。