gitlab-plugin icon indicating copy to clipboard operation
gitlab-plugin copied to clipboard

The "Never" option for "Rebuild open Merge Requests" does not prevent a build

Open tpbradt opened this issue 7 years ago • 29 comments

Issue

When setting up the Build Triggers for our Jenkins jobs, we use: Build when a change is pushed to GitLab = checked Opened Merge Request Events = checked Rebuild open Merge Requests = Never

The behavior with gitlab-plugin v1.1.32 was that when an open and previously failed merge request had a subsequent push, the build did NOT get triggered. When we upgraded to 1.4.5 this was no longer the case. A rebuild occurred even with the option set to Never. We recently upgraded to v1.5.1 and it is still triggering the rebuild. The documentation on the home page does not describe expected behavior for this configuration, but intuitively this seems broken to me.

Context

  • Gitlab plugin version: 1.5.1
  • Gitlab version: 10.2.4-ee
  • Jenkins version: 2.59
  • Job type: Maven project

Logs & Traces

Following is the Discussion in Gitlab: Dev Builder @devbld commented 24 minutes ago Developer

❎ Jenkins Build FAILURE

Results available at: Jenkins [diqfe-parent #77]

Dev Builder @devbld commented 24 minutes ago Developer

👎

Bradt Timothy P @bradttp added 1 commit 22 minutes ago 1b79cca6 - DOS-1016: Test if the new gitlab-plugin fixes the problem with "Never" rebuild… Compare with previous version

Dev Builder @devbld commented 21 minutes ago Developer

✅ Jenkins Build SUCCESS

Results available at: Jenkins [diqfe-parent #78]

Dev Builder @devbld commented 21 minutes ago Developer

👍

Dev Builder @devbld merged 21 minutes ago

These are the 2 Jenkins log entries showing the merge request triggered both builds: 14:52:37 Triggered by GitLab Merge Request #44: fe/dev_test_gitlab_plugin => master

14:54:52 Triggered by GitLab Merge Request #44: fe/dev_test_gitlab_plugin => master

Problem description

With the above configuration...

  1. Push a change that intentionally breaks a build.
  2. Create a merge request and verify the build fails and merge request remains open.
  3. Revert the change and push (i.e. fix broken build).
  4. Expect it to never rebuild, but a new build is triggered immediately/automatically.

tpbradt avatar Jan 17 '18 15:01 tpbradt

@tpbradt I was about to write a different reply, but I realized I'm not positive I understand what config you have set up for the plugin. Can you please attach a screenshot of the Jenkins job config where the plugin is configured?

omehegan avatar Jan 17 '18 23:01 omehegan

Sure. The screenshot highlights the 3 configurations I mentioned.

image

tpbradt avatar Jan 18 '18 15:01 tpbradt

@tpbradt you will need to add the screenshot via the GitHub issue web page, not replying to the email.

omehegan avatar Jan 19 '18 05:01 omehegan

Done. Edited original comment above.

tpbradt avatar Jan 19 '18 14:01 tpbradt

@tpbradt and what URL are you using for the webhook on the GitLab side, to trigger this build?

omehegan avatar Jan 22 '18 05:01 omehegan

http://devbld:(key)@jenkins.ops.cld/project/fe/mr/app-pld

...with the key masked out. Just to make it clear, we have our own gitlab locally.

tpbradt avatar Jan 22 '18 15:01 tpbradt

@tpbradt if you're still having this issue, can you follow the instructions in the User Support part of the README and attach logs from the plugin when you see a rebuild that should not happen?

omehegan avatar Mar 23 '18 06:03 omehegan

Here is a log from me reproducing just now. We have done some updates recently to our tools: Gitlab plugin version: 1.5.3 Gitlab version: 10.5.4-ee Jenkins version: 2.110

rebuild.log

tpbradt avatar Mar 26 '18 20:03 tpbradt

(Job config screenshot visible)

screenshot

omehegan avatar Apr 05 '18 05:04 omehegan

@tpbradt I can reproduce this. I'll see if I can figure out what the problem is. But I'm surprised no one else has seen it.

omehegan avatar Apr 05 '18 06:04 omehegan

@tpbradt what events have you set up in the webhook configuration in GitLab? Pushes and/or Merge Requests?

omehegan avatar Apr 06 '18 07:04 omehegan

Is there a workaround for this? Both "Never" and "Push to Source Branch" options for "Rebuild Open Merge Requests" do not work.

mmehra avatar Jun 04 '18 08:06 mmehra

@mmehra can you show me your webhook configuration from GitLab? Have you set up hooks for both pushes and MRs, or just MRs? Please follow the instructions in the User Support section of the README to increase debug logging for the plugin, and then attach those logs after you reproduce this issue.

omehegan avatar Jun 28 '18 06:06 omehegan

I realize this is somewhat of a thread hijack, but I am hitting the same issue as @mmehra: rebuilds are not happening at all: I have tried Rebuild open Merge Requests: On push to source branch and Rebuild open Merge Requests: On push to source or target branch

I have not tried pushing to the target branch to see if that triggers, but but pushes to the source branch do not trigger builds.

This is version 1.5.9 of the gitlab plugin, and version 2.141 of Jenkins.

jkugler avatar Sep 26 '18 19:09 jkugler

@omehegan Just figured out the issue (in my case).

These triggered builds:

  • Build trigger on merge request creation
  • Build trigger on merge request comment This did not:
  • Build trigger on new push to existing open merge request.

I looked at my config again, and realized I had it set to ignore WIP merge requests (which I was using since it was a test MR). So, now the bug is: why is it triggering builds on create and note when "ignore" is checked. :)

jkugler avatar Sep 26 '18 20:09 jkugler

@jkugler how were you marking the MRs as being WIP?

omehegan avatar Sep 27 '18 13:09 omehegan

@omehegan The subject started with WIP: per the GitLab convention. i.e. https://docs.gitlab.com/ee/user/project/merge_requests/work_in_progress_merge_requests.html

jkugler avatar Sep 27 '18 15:09 jkugler

Hello,

i read through this issue and issue #636. However I don't seem to find a solution for my problem.

Versions:

  • GitLab Plugin Version 1.5.9 (aso tested Version 1.5.10)

  • GitLab Community Edition 11.03

  • Jenkins Version 2.121.2

Jenkins Trigger Config:

  • Push Event (for commiting on source branch without having created an MR; not necessary!!!)

  • Opened Merge Request Events (for creating an MR)

  • Rebuild open Merge Requests: On push to source or target branch (for pushing on an open MR/ merging MR) (I actually activated all triggers, but would logically just need those.)

GitLab Webhooks

  • Push Events

  • Merge Requests Events

What I want to do: I'm working with a Jenkins pipeline and would like it to be triggered when creating an MR, pushing on an open MR, merging the MR (and ideally when commiting on source branch without having created an MR before; not required tho).

What happens: The Push Event (triggerAcionType: PUSH) triggers whenever Im commiting on the source branch (with and without open MR) and when I merge my source branch into master (with and without open MR). Creating a merge request (triggerAcionType: MERGE) on GitLab triggers the pipeline as well. Commiting on an open MR (triggerAcionType: MERGE) triggers the pipeline too, using the described trigger configuation. However as I'm using Push Events too, I have two Pipelines getting triggered. That blocks Jenkins unnecessarily. Merging the MR doesnt trigger the pipeline with following message:

Last commit in Merge Request has already been built in build #251

Result: I would like to just use the MR triggeres, as I dont necessarily need to build without having a MR opened and having two Pipelines triggered is not sufficient. However the MR Event doesn't trigger when merging.

Question:

  • Is there a workaround to trigger the merge with a MR (triggerAcionType: MERGE)?
  • Would a merge of a MR build the master (like the Push Event) or just rebuild the source branch? That' s how I understand the log message that I quoted above.

Thank you and please let me know, if Im missing Information, logs.

GoWithTheFlo95 avatar Oct 22 '18 12:10 GoWithTheFlo95

Do we have any updates? I got the same problem and its very important for us because "when build job" configuration is the main idea of plugin.

Osmyslitelny avatar Dec 07 '18 14:12 Osmyslitelny

@tpbradt what events have you set up in the webhook configuration in GitLab? Pushes and/or Merge Requests?

@omehegan Sorry I never got back to you. We trigger webhooks on merge request only.

tpbradt avatar Dec 07 '18 14:12 tpbradt

Look like I get this problem when json include "state" : "opened" and "action" : "update" with TriggerOpenMergeRequest.never

Osmyslitelny avatar Dec 07 '18 15:12 Osmyslitelny

I found the code which do this bug. On my jenkins I installed snapshot version and if you wanna, after some time, I can create Merge Request for project. p.s. I'm not sure that all my changes was correctly, but this bug is resolved into my snapshot.

Osmyslitelny avatar Dec 07 '18 17:12 Osmyslitelny

I have built a snapshot with the change from #869 which should fix the issue of builds getting triggered even when "Rebuild open merge requests" is set to "Never." For those affected by that issue, please try this and let us know if it fixes the problem. http://repo.jenkins-ci.org/snapshots/org/jenkins-ci/plugins/gitlab-plugin/1.5.12-SNAPSHOT/gitlab-plugin-1.5.12-20181217.052605-2.hpi

omehegan avatar Dec 17 '18 05:12 omehegan

@GoWithTheFlo95 it sounds like your issue would be resolved if we fix #636. Do you agree?

omehegan avatar Dec 17 '18 05:12 omehegan

@omehegan Just tried the build you provided 2 days ago and I can confirm it fixes the issue for me

nop00 avatar Dec 19 '18 13:12 nop00

@omehegan sorry for the late Reply, but yes this would fix my problem.

GoWithTheFlo95 avatar Mar 21 '19 14:03 GoWithTheFlo95

@omehegan Any update on when the fix will be merged ?

hazim1093 avatar Oct 24 '19 08:10 hazim1093

I'm experience the same issue when Accept the merge on GitLab, it is not trigger a new job on jenkins I'm using gitlab 12.5.8 jenkins 2.229 git plugin 4.2.2 gitlab_plugin 1.5.13

Do you have any idea about when it will be solved ?

zottinor avatar Apr 03 '20 19:04 zottinor

Hi Any plan to finish and release this fix?

yigalg avatar Jul 01 '21 15:07 yigalg