From acaab4d4050f9ce635bdfa5f4714477311115c90 Mon Sep 17 00:00:00 2001 From: Owen Mehegan Date: Mon, 26 Mar 2018 11:19:46 +1100 Subject: [PATCH] README: example of trigger configuration for multibranch jobs Replaces #684. --- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/README.md b/README.md index 12206ee..98a68ce 100644 --- a/README.md +++ b/README.md @@ -220,6 +220,40 @@ node { ### 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 ``http://JENKINS_URL/project/PROJECT_NAME`` or ``http://JENKINS_URL/project/FOLDER/PROJECT_NAME`` if the project in inside a folder in Jenkins. 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 here +def project_token = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEF' + +// Reference the GitLab connection name from your Jenkins Global configuration (http://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: "", + ] + ]) +]) +``` + ## Build status configuration You can optionally have your Jenkins jobs send their build status back to GitLab, where it will be displayed in the commit or merge request UI as appropriate.