jenkinsci / jenkinsci/gitlab-plugin

Labeling an open MR triggers a build

Open
#871 20 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
Java
Stars
1.4k
Forks
615
Avg merge
4h 32m
Merged PRs (30d)
10

Description

## Issue
When making minor changes to an open merge request that should not affect the result of the Jenkins run, a rebuild is triggered still.
This includes adding/removing a label, setting/removing a milestone, as well as editing the description (or title) of the MR.

**Note:** This issue is closely related to issue #696, which was closed as a duplicate to #633, which did not fix the issues described here (or in #696).

### Context
- **Gitlab plugin version**: 1.5.5
- **Gitlab version**: 10.4.6 EE
- **Jenkins version**: 2.138.2
- **Job type**: Freestyle

### Logs & Traces

Here's a log extract from Jenkins.
The relevant part is the `changes` section. In this case, I only changed the Milestone assignment for the MR:
```
WebHook called with url: /project/navi-builder

Dec 17, 2018 8:37:36 AM FINE com.dabsquared.gitlabjenkins.webhook.build.MergeRequestBuildAction

MergeRequest: {
"object_kind" : "merge_request",
"user" : {
"name" : "Frank Aurich",
"username" : "f.aurich",
"avatar_url" : ***FILTERED***
},
"project" : {
"id" : 1242,
"name" : ***FILTERED***,
"description" : "",
"web_url" : ***FILTERED***,
"avatar_url" : null,
"git_ssh_url" : ***FILTERED***,
"git_http_url" : ***FILTERED***,
"namespace" : ***FILTERED***,
"visibility_level" : 10,
"path_with_namespace" : ***FILTERED***,
"default_branch" : "mw_develop",
"ci_config_path" : null,
"homepage" : ***FILTERED***,
"url" : ***FILTERED***,
"ssh_url" : ***FILTERED***,
"http_url" : ***FILTERED***
},
"object_attributes" : {
"assignee_id" : 316,
"author_id" : 316,
"created_at" : "2018-12-14 17:18:58 +0100",
"description" : ***FILTERED***,
"head_pipeline_id" : 61912,
"id" : 26510,
"iid" : 63,
"last_edited_at" : "2018-12-14 17:19:30 +0100",
"last_edited_by_id" : 316,
"merge_commit_sha" : null,
"merge_error" : null,
"merge_params" : {
"force_remove_source_branch" : "1"
},
"merge_status" : "can_be_merged",
"merge_user_id" : null,
"merge_when_pipeline_succeeds" : false,
"milestone_id" : 4676,
"source_branch" : "bugfix/DEFECT-34585",
"source_project_id" : 1242,
"state" : "opened",
"target_branch" : "mw_develop",
"target_project_id" : 1242,
"time_estimate" : 0,
"title" : ***FILTERED***,
"updated_at" : "2018-12-17 08:37:35 +0100",
"updated_by_id" : 83,
"url" : ***FILTERED***,
"source" : {
"id" : 1242,
"name" : ***FILTERED***,
"description" : "",
"web_url" : ***FILTERED***,
"avatar_url" : null,
"git_ssh_url" : ***FILTERED***,
"git_http_url" : ***FILTERED***,
"namespace" : ***FILTERED***,
"visibility_level" : 10,
"path_with_namespace" : ***FILTERED***,
"default_branch" : "mw_develop",
"ci_config_path" : null,
"homepage" : ***FILTERED***,
"url" : ***FILTERED***,
"ssh_url" : ***FILTERED***,
"http_url" : ***FILTERED***
},
"target" : {
"id" : 1242,
"name" : ***FILTERED***,
"description" : "",
"web_url" : ***FILTERED***,
"avatar_url" : null,
"git_ssh_url" : ***FILTERED***,
"git_http_url" : ***FILTERED***,
"namespace" : ***FILTERED***,
"visibility_level" : 10,
"path_with_namespace" : ***FILTERED***,
"default_branch" : "mw_develop",
"ci_config_path" : null,
"homepage" : ***FILTERED***,
"url" : ***FILTERED***,
"ssh_url" : ***FILTERED***,
"http_url" : ***FILTERED***
},
"last_commit" : {
"id" : "1e2c74baffb976fe16e8cfe2490826609009a1a8",
"message" : ***FILTERED***,
"timestamp" : "2018-12-14T17:10:24+01:00",
"url" : ***FILTERED***,
"author" : {
"name" : ***FILTERED***,
"email" : ***FILTERED***
}
},
"work_in_progress" : false,
"total_time_spent" : 0,
"human_total_time_spent" : null,
"human_time_estimate" : null,
"action" : "update"
},
"labels" : [ ],
"changes" : {
"milestone_id" : {
"previous" : null,
"current" : 4676
},
"updated_at" : {
"previous" : "2018-12-17 08:35:19 +0100",
"current" : "2018-12-17 08:37:35 +0100"
},
"updated_by_id" : {
"previous" : 316,
"current" : 83
}
},
"repository" : {
"name" : ***FILTERED***,
"url" : ***FILTERED***,
"description" : "",
"homepage" : ***FILTERED***
},
"assignee" : {
"name" : ***FILTERED***,
"username" : ***FILTERED***,
"avatar_url" : ***FILTERED***
}
}

Dec 17, 2018 8:37:36 AM INFO com.dabsquared.gitlabjenkins.trigger.handler.AbstractWebHookTriggerHandler handle

navi-builder triggered for merge request.
```
Here is `changes` section after a new label has been added to an MR:
```
[...]
"changes" : {
"labels" : {
"previous" : [ ],
"current" : [ {
"id" : 3348,
"title" : "X137",
"color" : "#44AD8E",
"project_id" : null,
"created_at" : "2018-12-17 08:40:27 +0100",
"updated_at" : "2018-12-17 08:40:27 +0100",
"template" : false,
"description" : "Relevant SW change for SW137",
"type" : "GroupLabel",
"group_id" : 43
} ]
}
},
[...]
```

### Problem description

In Gitlab, a webhook is configured to be triggered on `Merge Request` and `Comment`.
**Expected:**
Jenkins starts a new build job when new commits to the MR branch occur, or when someone triggers the Jenkins manually via a special comment in Gitlab.
**Actual:**
Jenkins triggers a job when changes are made to the MR that are not relevant to the Jenkins build:
label changes, milestone changes, changes to the description of the MR, changes to the number of approvers (Gitlab EE).

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.