I've started lately to use Jenkins and i need some help with creating a pipeline.
I want to create the following pipeline: For each merge request from develop to master in Gitlab, Trigger a Jenkins job that run an end-to-end test, And merge the branches in Gitlab only if the test succeeded.
I have found the following article that gives me an explanation for most of the things that i need: https://vetlugin.wordpress.com/2017/01/31/guide-jenkins-pipeline-merge-requests/
I'm still looking for an answer for one question: How can Jenkins response to Gitlab with the result of the end-to-end test (Success/Fail), So Gitlab will know whether to merge to branches or not?
Please advise, Thanks!
You do not tell us how Gitlab and Jenkins are connected, but I'll assume you use the Jenkins Gitlab plugin https://github.com/jenkinsci/gitlab-plugin. If you're not, maybe you should :)
With this plugin, you can 'integrate' more deeply Jenkins and Gitlab, and your Jenkins builds will send back to Gitlab the result of the build. You will see something like this https://raw.githubusercontent.com/teeks99/gitlab-plugin-wiki-images/master/Setup_Example_img/Result_commit.png. Build results are marked near the commit which has been tested.
In this case, for each merge request, you can check the "Merge if build succeed" button (see https://raw.githubusercontent.com/teeks99/gitlab-plugin-wiki-images/master/Setup_Example_img/Merge_progress.png) to auto merge the code when build is successful.
Look at the Jenkins Gitlab plugin README for more information and advanced setup, like test in your build the result of the merge, etc.
So Gitlab will know whether to merge to branches or not?
GitLab itself does not have to be aware of this test result to, on its own decide to merge or not.
Your Jenkins job should, it the test is successful, call the right GitLab API in order to accept the MR (Merge Request).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With