Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trigger jobs in gitlab-ci on merge request

It's posible run a job from gitlab-ci only on merge request? Now, we have a big monolitic project with heavy tests, but we only want to run the test before merging to the branch master.

like image 558
Philippe Thiers Avatar asked May 11 '17 14:05

Philippe Thiers


Video Answer


3 Answers

Well, it's not built in currently however it's not impossible to do it yourself. Gitlab allows to trigger a job. It also supports webhooks on merge requests. However webhooks don't support variable in URIs and triggers can't read request body so you'd have to create a script that will act like a middle-man here:

  1. Webhook on merge request calls to your script
  2. Script parses the request and calls a triggers in gitlab with correct REF
  3. Trigger runs the job that is marked with;

    only: -triggers

It's a bit hacky but it's working and easy to implement.

like image 87
Jakub Kania Avatar answered Oct 03 '22 08:10

Jakub Kania


This is now possible. This has been introduced in GitLab 11.6.

like image 42
Nicolas Pepinster Avatar answered Oct 03 '22 08:10

Nicolas Pepinster


For the moment, no. You should subscribe the issue to see if and when they will be available (and if your company is a enterprise customer, maybe you can contact them to ask to prioritize the implementation)

like image 27
rpadovani Avatar answered Oct 03 '22 06:10

rpadovani