A plugin that allows jenkins to build merge requests in Gitlab
A plugin that allows Jenkins to build merge requests.
This plugin fetches the source and target branches of a Gitlab merge request and makes them available
to your build via build parameters. Once the build completes, Jenkins will leave a comment on the merge
request indicating whether the merge request was successful.
Jenkins -> Manage Plugins -> AvailableGitlab Merge Request BuilderManage Jenkins -> Configure System -> Gitlab Merge Request BuilderGitlab Host URL to the base URL of your Gitlab serverJenkins Username for the Jenkins user (defaults to jenkins)Jenkins API Token for the Jenkins user. This can be found by logging into Gitlab as JenkinsSave to preserve your changes.Manage Jenkins -> Configure Global Security and set Markup Formatter to Safe HTML. It will make Jenkins display links in build history properly.New JobProject NameGitHub Project URL as the URL for the Gitlab project (if you have the GitHub plugin installed)Source Code Management section:
Git and enter your Repository URL and in Advanced set its Name to origin${gitlabSourceRepository} and in Advanced set Name to ${gitlabSourceName}Branch Specifier enter refs/remotes/origin/${gitlabSourceBranch} or for merge requests from forked repositories enter ${gitlabSourceName}/${gitlabSourceBranch}Additional Behaviours section:
Add drop down button and the Merge before build itemorigin (if origin corresponds to Gitlab) and enter theBranch to merge to as ${gitlabTargetBranch}Prune stale remote-tracking branches is not addedBuild Triggers section:
Gitlab Merge Requests BuilderGitlab Project Path, this might be something like your_group/your_project for Gitlab URL http://git.tld/your_group/your_projectTarget Branch Regex may be configured to whitelist this job for certain target branches. If left empty, every valid merge request for the configured project path will trigger this job.Use HTTP(S) URL checkbox should be used if you want Jenkins toSave to preserve your changesChanging any of the filters to an empty string will remove the filters
You can trigger a job a manually by clicking This build is parameterized and adding the relevant build parameters.
These include:
Note: a manually triggered build will not add build triggered/succeeded/failed comments to the merge request.
Note: You should ensure that the ‘Global Config user.name Value’ and ‘Global Config user.email Value’ are both set for your git plugin. In some cases, you will get an error indicating that a branch cannot be merged if these are not set.
Copyright © 2013 Tim Olshansky. See LICENSE for further details.