Pipeline Multibranch jobs

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. git@git.your-domain.com: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’))
}
}
}

上一篇:Anaconda常用命令


下一篇:Configure the test environment to trust the connection - RSAT with Dynamics 365