jenkinsci / jenkinsci/gitlab-plugin

closed MR is triggering build even with "closed merge requests events" unchecked

Open
#1,020 1 comment 0 reactions 1 assignee Claimed by @markjacksonfishing View on GitHub
needs review newbie-friendly
Dominant language
Java
Stars
1.4k
Forks
615
Avg merge
4h 32m
Merged PRs (30d)
10

Description

## Issue

Hi,

It has been working great with accepted MR, but with "Closed Merge Request Events" unchecked, I found closed MR is still triggering build in Jenkins.

### Context
- **Gitlab plugin version**: 1.5.12
- **Gitlab version**: 12.5.7-ce
- **Jenkins version**: 2.204.1
- **Job type**: Freestyle

### Logs & Traces

Jan 16, 2020 9:48:06 AM INFO com.dabsquared.gitlabjenkins.webhook.GitLabWebHook getDynamic

WebHook called with url: /project/mytool%20Build/01-mytool-deps

Jan 16, 2020 9:48:06 AM FINE com.dabsquared.gitlabjenkins.webhook.build.MergeRequestBuildAction

MergeRequest: {
"object_kind" : "merge_request",
"event_type" : "merge_request",
"user" : {
"name" : "User1",
"username" : "user1",
"avatar_url" : "https://gitlab.some.server.com/uploads/-/system/user/avatar/90/avatar.png"
},
"project" : {
"id" : 11,
"name" : "mytool",
"description" : "This is my tool.\r\n",
"web_url" : "https://gitlab.some.server.com/mydept/mytool",
"avatar_url" : null,
"git_ssh_url" : "ssh://git@gitlab.some.server.com:1234/mydept/mytool.git",
"git_http_url" : "https://gitlab.some.server.com/mydept/mytool.git",
"namespace" : "mydept",
"visibility_level" : 10,
"path_with_namespace" : "mydept/mytool",
"default_branch" : "master",
"ci_config_path" : null,
"homepage" : "https://gitlab.some.server.com/mydept/mytool",
"url" : "ssh://git@gitlab.some.server.com:1234/mydept/mytool.git",
"ssh_url" : "ssh://git@gitlab.some.server.com:1234/mydept/mytool.git",
"http_url" : "https://gitlab.some.server.com/mydept/mytool.git"
},
"object_attributes" : {
"assignee_id" : 13,
"author_id" : 90,
"created_at" : "2020-01-15 21:27:46 UTC",
"description" : "finished feature request",
"head_pipeline_id" : null,
"id" : 211,
"iid" : 191,
"last_edited_at" : "2020-01-16 14:42:27 UTC",
"last_edited_by_id" : 90,
"merge_commit_sha" : null,
"merge_error" : null,
"merge_params" : {
"force_remove_source_branch" : "0"
},
"merge_status" : "can_be_merged",
"merge_user_id" : null,
"merge_when_pipeline_succeeds" : false,
"milestone_id" : null,
"source_branch" : "Feature-1007",
"source_project_id" : 11,
"state" : "closed",
"target_branch" : "master",
"target_project_id" : 11,
"time_estimate" : 0,
"title" : "Feature-1007",
"updated_at" : "2020-01-16 14:48:05 UTC",
"updated_by_id" : 90,
"url" : "https://gitlab.some.server.com/mydept/mytool/merge_requests/191",
"source" : {
"id" : 11,
"name" : "mytool",
"description" : "This is my tool.\r\n",
"web_url" : "https://gitlab.some.server.com/mydept/mytool",
"avatar_url" : null,
"git_ssh_url" : "ssh://git@gitlab.some.server.com:1234/mydept/mytool.git",
"git_http_url" : "https://gitlab.some.server.com/mydept/mytool.git",
"namespace" : "mydept",
"visibility_level" : 10,
"path_with_namespace" : "mydept/mytool",
"default_branch" : "master",
"ci_config_path" : null,
"homepage" : "https://gitlab.some.server.com/mydept/mytool",
"url" : "ssh://git@gitlab.some.server.com:1234/mydept/mytool.git",
"ssh_url" : "ssh://git@gitlab.some.server.com:1234/mydept/mytool.git",
"http_url" : "https://gitlab.some.server.com/mydept/mytool.git"
},
"target" : {
"id" : 11,
"name" : "mytool",
"description" : "This is my tool.\r\n",
"web_url" : "https://gitlab.some.server.com/mydept/mytool",
"avatar_url" : null,
"git_ssh_url" : "ssh://git@gitlab.some.server.com:1234/mydept/mytool.git",
"git_http_url" : "https://gitlab.some.server.com/mydept/mytool.git",
"namespace" : "mydept",
"visibility_level" : 10,
"path_with_namespace" : "mydept/mytool",
"default_branch" : "master",
"ci_config_path" : null,
"homepage" : "https://gitlab.some.server.com/mydept/mytool",
"url" : "ssh://git@gitlab.some.server.com:1234/mydept/mytool.git",
"ssh_url" : "ssh://git@gitlab.some.server.com:1234/mydept/mytool.git",
"http_url" : "https://gitlab.some.server.com/mydept/mytool.git"
},
"last_commit" : {
"id" : "40a8e77d4ed7813a6c82370672891b7692bd01d6",
"message" : "finished feature request",
"timestamp" : "2020-01-16T09:40:37-05:00",
"url" : "https://gitlab.some.server.com/mydept/mytool/commit/40a8e77d4ed7813a6c82370672891b7692bd01d6",
"author" : {
"name" : "user1",
"email" : "user1@some.server.com"
}
},
"work_in_progress" : false,
"total_time_spent" : 0,
"human_total_time_spent" : null,
"human_time_estimate" : null,
"assignee_ids" : [ 13 ],
"action" : "close"
},
"labels" : [ ],
"changes" : {
"state" : {
"previous" : "opened",
"current" : "closed"
},
"updated_at" : {
"previous" : "2020-01-16 14:42:27 UTC",
"current" : "2020-01-16 14:48:05 UTC"
},
"assignees" : {
"previous" : [ ],
"current" : [ {
"name" : "user2",
"username" : "user2",
"avatar_url" : "https://secure.gravatar.com/avatar/7ca9c6785bade2806956c63f4f00d905?s=80&d=identicon"
} ]
},
"total_time_spent" : {
"previous" : null,
"current" : 0
}
},
"repository" : {
"name" : "mytool",
"url" : "ssh://git@gitlab.some.server.com:1234/mydept/mytool.git",
"description" : "This is my tool.\r\n",
"homepage" : "https://gitlab.some.server.com/mydept/mytool"
},
"assignees" : [ {
"name" : "user2",
"username" : "user2",
"avatar_url" : "https://secure.gravatar.com/avatar/7ca9c6785bade2806956c63f4f00d905?s=80&d=identicon"
} ]
}

Jan 16, 2020 9:48:06 AM INFO com.dabsquared.gitlabjenkins.trigger.handler.AbstractWebHookTriggerHandler handle

MyTool Build/01-mytool-deps triggered for merge request.

### Problem description

- The MR was simply abandoned and closed ("state": closed")`, and not merged ("merge_status" : "can_be_merged")
- I wouldn't expect the plugin to still trigger the build
- Yet, it was accepted and triggered to build

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.