Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close merge request build are not triggered in version 1.5.10 and 1.5.11 #891

Open
haminhcong opened this issue Feb 3, 2019 · 4 comments

Comments

@haminhcong
Copy link

Issue

Context

  • Gitlab plugin version: 1.5.11 and 1.5.10
  • Gitlab version: 10.8.6-ce
  • Jenkins version: 2.150.2
  • Job type: Pipeline

I have a CI system with jenkins and Gitlab. Three months ago, my boss upgade gitlab plugin from 1.5.9 to 1.5.10. A day later, i close a merge request and see that close merge request event are not trigger any build, although I still see merge request hook still received and handled by Gitlab plugin.

Then i go to my PC and setup a demo environment with gitlab v10 and v11, with Jenkins Gitlab plugin version is 1.5.9, and merge request build work again. Therefore, i think that we has some problem with Jenkins Gitlab plugin version 1.5.10 and 1.5.11.

Can you help me resolve this problem ? Thank you very much.

Below is logs in Jenkins log from my test when i click "close merge request" button in gitlab.

Logs & Traces

With v1.5.10 and v1.5.11

Feb 03, 2019 10:23:32 AM INFO com.dabsquared.gitlabjenkins.webhook.GitLabWebHook getDynamic

WebHook called with url: /project/spring_test_close_mr

Feb 03, 2019 10:23:32 AM FINE com.dabsquared.gitlabjenkins.webhook.build.MergeRequestBuildAction

MergeRequest: {
  "object_kind" : "merge_request",
  "event_type" : "merge_request",
  "user" : {
    "name" : "cicd_bot",
    "username" : "cicd_bot",
    "avatar_url" : "https://www.gravatar.com/avatar/4544bb20d88b39400e2b1a8262b9d875?s=80&d=identicon"
  },
  "project" : {
    "id" : 1,
    "name" : "spring_test",
    "description" : "",
    "web_url" : "http://gitlab:8180/cicd_bot/spring_test",
    "avatar_url" : null,
    "git_ssh_url" : "ssh://git@gitlab:8122/cicd_bot/spring_test.git",
    "git_http_url" : "http://gitlab:8180/cicd_bot/spring_test.git",
    "namespace" : "cicd_bot",
    "visibility_level" : 20,
    "path_with_namespace" : "cicd_bot/spring_test",
    "default_branch" : "master",
    "ci_config_path" : null,
    "homepage" : "http://gitlab:8180/cicd_bot/spring_test",
    "url" : "ssh://git@gitlab:8122/cicd_bot/spring_test.git",
    "ssh_url" : "ssh://git@gitlab:8122/cicd_bot/spring_test.git",
    "http_url" : "http://gitlab:8180/cicd_bot/spring_test.git"
  },
  "object_attributes" : {
    "assignee_id" : null,
    "author_id" : 2,
    "created_at" : "2019-02-03 10:21:59 UTC",
    "description" : "",
    "head_pipeline_id" : null,
    "id" : 5,
    "iid" : 5,
    "last_edited_at" : null,
    "last_edited_by_id" : null,
    "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" : "test-mr",
    "source_project_id" : 1,
    "state" : "closed",
    "target_branch" : "master",
    "target_project_id" : 1,
    "time_estimate" : 0,
    "title" : "Test mr",
    "updated_at" : "2019-02-03 10:23:32 UTC",
    "updated_by_id" : null,
    "url" : "http://gitlab:8180/cicd_bot/spring_test/merge_requests/5",
    "source" : {
      "id" : 1,
      "name" : "spring_test",
      "description" : "",
      "web_url" : "http://gitlab:8180/cicd_bot/spring_test",
      "avatar_url" : null,
      "git_ssh_url" : "ssh://git@gitlab:8122/cicd_bot/spring_test.git",
      "git_http_url" : "http://gitlab:8180/cicd_bot/spring_test.git",
      "namespace" : "cicd_bot",
      "visibility_level" : 20,
      "path_with_namespace" : "cicd_bot/spring_test",
      "default_branch" : "master",
      "ci_config_path" : null,
      "homepage" : "http://gitlab:8180/cicd_bot/spring_test",
      "url" : "ssh://git@gitlab:8122/cicd_bot/spring_test.git",
      "ssh_url" : "ssh://git@gitlab:8122/cicd_bot/spring_test.git",
      "http_url" : "http://gitlab:8180/cicd_bot/spring_test.git"
    },
    "target" : {
      "id" : 1,
      "name" : "spring_test",
      "description" : "",
      "web_url" : "http://gitlab:8180/cicd_bot/spring_test",
      "avatar_url" : null,
      "git_ssh_url" : "ssh://git@gitlab:8122/cicd_bot/spring_test.git",
      "git_http_url" : "http://gitlab:8180/cicd_bot/spring_test.git",
      "namespace" : "cicd_bot",
      "visibility_level" : 20,
      "path_with_namespace" : "cicd_bot/spring_test",
      "default_branch" : "master",
      "ci_config_path" : null,
      "homepage" : "http://gitlab:8180/cicd_bot/spring_test",
      "url" : "ssh://git@gitlab:8122/cicd_bot/spring_test.git",
      "ssh_url" : "ssh://git@gitlab:8122/cicd_bot/spring_test.git",
      "http_url" : "http://gitlab:8180/cicd_bot/spring_test.git"
    },
    "last_commit" : {
      "id" : "dfc260d71bafb33bbdf04033b13199bf254c6c88",
      "message" : "test again\n",
      "timestamp" : "2019-01-30T22:39:26+07:00",
      "url" : "http://gitlab:8180/cicd_bot/spring_test/commit/dfc260d71bafb33bbdf04033b13199bf254c6c88",
      "author" : {
        "name" : "cicd_bot",
        "email" : "conghm96@gmail.com"
      }
    },
    "work_in_progress" : false,
    "total_time_spent" : 0,
    "human_total_time_spent" : null,
    "human_time_estimate" : null,
    "action" : "close"
  },
  "labels" : [ ],
  "changes" : {
    "state" : {
      "previous" : "opened",
      "current" : "closed"
    },
    "updated_at" : {
      "previous" : "2019-02-03 10:21:59 UTC",
      "current" : "2019-02-03 10:23:32 UTC"
    },
    "total_time_spent" : {
      "previous" : null,
      "current" : 0
    }
  },
  "repository" : {
    "name" : "spring_test",
    "url" : "ssh://git@gitlab:8122/cicd_bot/spring_test.git",
    "description" : "",
    "homepage" : "http://gitlab:8180/cicd_bot/spring_test"
  }
}
// end of log.

With v1.5.9

WebHook called with url: /project/spring_test_close_mr

Feb 03, 2019 11:43:30 AM FINE com.dabsquared.gitlabjenkins.webhook.build.MergeRequestBuildAction

MergeRequest: {
  "object_kind" : "merge_request",
  "event_type" : "merge_request",
  "user" : {
    "name" : "cicd_bot",
    "username" : "cicd_bot",
    "avatar_url" : "https://www.gravatar.com/avatar/4544bb20d88b39400e2b1a8262b9d875?s=80&d=identicon"
  },
  "project" : {
    "id" : 1,
    "name" : "spring_test",
    "description" : "",
    "web_url" : "http://gitlab:8180/cicd_bot/spring_test",
    "avatar_url" : null,
    "git_ssh_url" : "ssh://git@gitlab:8122/cicd_bot/spring_test.git",
    "git_http_url" : "http://gitlab:8180/cicd_bot/spring_test.git",
    "namespace" : "cicd_bot",
    "visibility_level" : 20,
    "path_with_namespace" : "cicd_bot/spring_test",
    "default_branch" : "master",
    "ci_config_path" : null,
    "homepage" : "http://gitlab:8180/cicd_bot/spring_test",
    "url" : "ssh://git@gitlab:8122/cicd_bot/spring_test.git",
    "ssh_url" : "ssh://git@gitlab:8122/cicd_bot/spring_test.git",
    "http_url" : "http://gitlab:8180/cicd_bot/spring_test.git"
  },
  "object_attributes" : {
    "assignee_id" : null,
    "author_id" : 2,
    "created_at" : "2019-02-03 11:43:27 UTC",
    "description" : "",
    "head_pipeline_id" : null,
    "id" : 7,
    "iid" : 7,
    "last_edited_at" : null,
    "last_edited_by_id" : null,
    "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" : "test-mr",
    "source_project_id" : 1,
    "state" : "closed",
    "target_branch" : "master",
    "target_project_id" : 1,
    "time_estimate" : 0,
    "title" : "Test mr",
    "updated_at" : "2019-02-03 11:43:30 UTC",
    "updated_by_id" : null,
    "url" : "http://gitlab:8180/cicd_bot/spring_test/merge_requests/7",
    "source" : {
      "id" : 1,
      "name" : "spring_test",
      "description" : "",
      "web_url" : "http://gitlab:8180/cicd_bot/spring_test",
      "avatar_url" : null,
      "git_ssh_url" : "ssh://git@gitlab:8122/cicd_bot/spring_test.git",
      "git_http_url" : "http://gitlab:8180/cicd_bot/spring_test.git",
      "namespace" : "cicd_bot",
      "visibility_level" : 20,
      "path_with_namespace" : "cicd_bot/spring_test",
      "default_branch" : "master",
      "ci_config_path" : null,
      "homepage" : "http://gitlab:8180/cicd_bot/spring_test",
      "url" : "ssh://git@gitlab:8122/cicd_bot/spring_test.git",
      "ssh_url" : "ssh://git@gitlab:8122/cicd_bot/spring_test.git",
      "http_url" : "http://gitlab:8180/cicd_bot/spring_test.git"
    },
    "target" : {
      "id" : 1,
      "name" : "spring_test",
      "description" : "",
      "web_url" : "http://gitlab:8180/cicd_bot/spring_test",
      "avatar_url" : null,
      "git_ssh_url" : "ssh://git@gitlab:8122/cicd_bot/spring_test.git",
      "git_http_url" : "http://gitlab:8180/cicd_bot/spring_test.git",
      "namespace" : "cicd_bot",
      "visibility_level" : 20,
      "path_with_namespace" : "cicd_bot/spring_test",
      "default_branch" : "master",
      "ci_config_path" : null,
      "homepage" : "http://gitlab:8180/cicd_bot/spring_test",
      "url" : "ssh://git@gitlab:8122/cicd_bot/spring_test.git",
      "ssh_url" : "ssh://git@gitlab:8122/cicd_bot/spring_test.git",
      "http_url" : "http://gitlab:8180/cicd_bot/spring_test.git"
    },
    "last_commit" : {
      "id" : "dfc260d71bafb33bbdf04033b13199bf254c6c88",
      "message" : "test again\n",
      "timestamp" : "2019-01-30T22:39:26+07:00",
      "url" : "http://gitlab:8180/cicd_bot/spring_test/commit/dfc260d71bafb33bbdf04033b13199bf254c6c88",
      "author" : {
        "name" : "cicd_bot",
        "email" : "conghm96@gmail.com"
      }
    },
    "work_in_progress" : false,
    "total_time_spent" : 0,
    "human_total_time_spent" : null,
    "human_time_estimate" : null,
    "action" : "close"
  },
  "labels" : [ ],
  "changes" : {
    "state" : {
      "previous" : "opened",
      "current" : "closed"
    },
    "updated_at" : {
      "previous" : "2019-02-03 11:43:27 UTC",
      "current" : "2019-02-03 11:43:30 UTC"
    },
    "total_time_spent" : {
      "previous" : null,
      "current" : 0
    }
  },
  "repository" : {
    "name" : "spring_test",
    "url" : "ssh://git@gitlab:8122/cicd_bot/spring_test.git",
    "description" : "",
    "homepage" : "http://gitlab:8180/cicd_bot/spring_test"
  }
}

Feb 03, 2019 11:43:30 AM INFO com.dabsquared.gitlabjenkins.trigger.handler.AbstractWebHookTriggerHandler handle

spring_test_close_mr triggered for merge request.
// end of log

Here is my jenkins job configuration:

bash-4.4# cat /var/jenkins_home/jobs/spring_test_close_mr/config.xml

<?xml version='1.1' encoding='UTF-8'?>
<flow-definition plugin="workflow-job@2.23">
  <actions/>
  <description></description>
  <keepDependencies>false</keepDependencies>
  <properties>
    <com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty plugin="gitlab-plugin@1.5.9">
      <gitLabConnection>gitlab_local</gitLabConnection>
    </com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty>
    <org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
      <triggers>
        <com.dabsquared.gitlabjenkins.GitLabPushTrigger plugin="gitlab-plugin@1.5.9">
          <spec></spec>
          <triggerOnPush>false</triggerOnPush>
          <triggerOnMergeRequest>false</triggerOnMergeRequest>
          <triggerOnPipelineEvent>false</triggerOnPipelineEvent>
          <triggerOnAcceptedMergeRequest>false</triggerOnAcceptedMergeRequest>
          <triggerOnClosedMergeRequest>true</triggerOnClosedMergeRequest>
          <triggerOnApprovedMergeRequest>false</triggerOnApprovedMergeRequest>
          <triggerOpenMergeRequestOnPush>both</triggerOpenMergeRequestOnPush>
          <triggerOnNoteRequest>false</triggerOnNoteRequest>
          <noteRegex>Jenkins please retry a build</noteRegex>
          <ciSkip>false</ciSkip>
          <skipWorkInProgressMergeRequest>false</skipWorkInProgressMergeRequest>
          <setBuildDescription>true</setBuildDescription>
          <branchFilterType>All</branchFilterType>
          <includeBranchesSpec></includeBranchesSpec>
          <excludeBranchesSpec></excludeBranchesSpec>
          <targetBranchRegex></targetBranchRegex>
          <secretToken>{AQAAABAAAAAwb8+Lwmf9nkmswf4/mE6lEctG+9DN1Mq4K67QabxGnnPBNjl+abI6N0vW4xVh5Am9E5Wll2HbfUZ5gZUrcmkDMg==}</secretToken>
          <pendingBuildName></pendingBuildName>
          <cancelPendingBuildsOnUpdate>false</cancelPendingBuildsOnUpdate>
        </com.dabsquared.gitlabjenkins.GitLabPushTrigger>
      </triggers>
    </org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
  </properties>
  <definition class="org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition" plugin="workflow-cps@2.54">
    <script>echo &quot;connected&quot;</script>
    <sandbox>true</sandbox>
  </definition>
  <triggers/>
  <disabled>false</disabled>
</flow-definition>
@sniiick
Copy link

sniiick commented Mar 4, 2019

Same problem. Seems that already triggered builds from "Open MR events" or "Push events" on same commit hash blocks from triggering on MR closing. Just deleted recently built builds and close event was correctly handled.

@haminhcong
Copy link
Author

@snicks92 The problem is close MR is not handled correctly after version 1.5.10.

Start from commit fe6b1b1, chain of general OR conditions is used for allow or deny a merrge request build. In Enum Action, we have theses action is accepted

package com.dabsquared.gitlabjenkins.gitlab.hook.model;

/**
 * @author Robin Müller
 */
public enum Action {
    open, update, approved, merge, closed, reopen
}

but when we click to close Merge Request, the close merge request hook sent to Jenkins has following content:

{
  "object_kind": "merge_request",
  "event_type": "merge_request",
  "user": {
    "name": "user",
    "username": "user",
    "avatar_url": "http://privateURL"
  },
  "project": {
    "id": 11,
    "name": "private-repository",
    "description": "repository",
    "web_url": "http://192.168.120.2:8180/private_repo",
    "avatar_url": null,
    "git_ssh_url": "ssh://git@192.168.120.2:8122/private_repo.git",
    "git_http_url": "http://192.168.120.2:8180/private_repo.git",
    "namespace": "user",
    "visibility_level": 0,
    "path_with_namespace": "private_repo",
    "default_branch": "master",
    "ci_config_path": null,
    "homepage": "http://192.168.120.2:8180/private_repo",
    "url": "ssh://git@192.168.120.2:8122/private_repo.git",
    "ssh_url": "ssh://git@192.168.120.2:8122/private_repo.git",
    "http_url": "http://192.168.120.2:8180/private_repo.git"
  },
  "object_attributes": {
    "assignee_id": null,
    "author_id": 5,
    "created_at": "2019-03-25 09:29:04 UTC",
    "description": "",
    "head_pipeline_id": 4833,
    "id": 972,
    "iid": 7,
    "last_edited_at": null,
    "last_edited_by_id": null,
    "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": "check-mr-2",
    "source_project_id": 11,
    "state": "closed",
    "target_branch": "check-mr",
    "target_project_id": 11,
    "time_estimate": 0,
    "title": "Test again",
    "updated_at": "2019-03-28 01:16:53 UTC",
    "updated_by_id": null,
    "url": "http://192.168.120.2:8180/private_repo/merge_requests/7",
    "source": {
      "id": 11,
      "name": "private-repository",
      "description": "private repository application",
      "web_url": "http://192.168.120.2:8180/private_repo",
      "avatar_url": null,
      "git_ssh_url": "ssh://git@192.168.120.2:8122/private_repo.git",
      "git_http_url": "http://192.168.120.2:8180/private_repo.git",
      "namespace": "user",
      "visibility_level": 0,
      "path_with_namespace": "private_repo",
      "default_branch": "master",
      "ci_config_path": null,
      "homepage": "http://192.168.120.2:8180/private_repo",
      "url": "ssh://git@192.168.120.2:8122/private_repo.git",
      "ssh_url": "ssh://git@192.168.120.2:8122/private_repo.git",
      "http_url": "http://192.168.120.2:8180/private_repo.git"
    },
    "target": {
      "id": 11,
      "name": "private-repository",
      "description": "private repository application",
      "web_url": "http://192.168.120.2:8180/private_repo",
      "avatar_url": null,
      "git_ssh_url": "ssh://git@192.168.120.2:8122/private_repo.git",
      "git_http_url": "http://192.168.120.2:8180/private_repo.git",
      "namespace": "user",
      "visibility_level": 0,
      "path_with_namespace": "private_repo",
      "default_branch": "master",
      "ci_config_path": null,
      "homepage": "http://192.168.120.2:8180/private_repo",
      "url": "ssh://git@192.168.120.2:8122/private_repo.git",
      "ssh_url": "ssh://git@192.168.120.2:8122/private_repo.git",
      "http_url": "http://192.168.120.2:8180/private_repo.git"
    },
    "last_commit": {
      "id": "6c63bff3382f47e54fab2e036697b21a351f1ebe",
      "message": "Re check\n",
      "timestamp": "2019-03-26T01:07:17Z",
      "url": "http://192.168.120.2:8180/private_repo/commit/6c63bff3382f47e54fab2e036697b21a351f1ebe",
      "author": {
        "name": "user",
        "email": "user@gmail.com.vn"
      }
    },
    "work_in_progress": false,
    "total_time_spent": 0,
    "human_total_time_spent": null,
    "human_time_estimate": null,
    "action": "close"
  },
  "labels": [

  ],
  "changes": {
    "state": {
      "previous": "opened",
      "current": "closed"
    },
    "updated_at": {
      "previous": "2019-03-27 09:42:59 UTC",
      "current": "2019-03-28 01:16:53 UTC"
    },
    "total_time_spent": {
      "previous": null,
      "current": 0
    }
  },
  "repository": {
    "name": "private-repository",
    "url": "ssh://git@192.168.120.2:8122/private_repo.git",
    "description": "repo application",
    "homepage": "http://192.168.120.2:8180/private_repo"
  }
}

the action attribute value is close, not closed.

    "action": "close"

because of this, the mergeRequestHook object converted from request hook content has null value in objectAttributes.action field (because close not exists in Action enum)

    public MergeRequestBuildAction(Item project, String json, String secretToken) {
        LOGGER.log(Level.FINE, "MergeRequest: {0}", toPrettyPrint(json));
        this.project = project;
        this.mergeRequestHook = JsonUtil.read(json, MergeRequestHook.class);
        this.secretToken = secretToken;
    }

then this null value is reject by rejectRules filter in TriggerConfigChain, and Close Merge Request Build is dropped:

class MergeRequestHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<MergeRequestHook> implements MergeRequestHookTriggerHandler {
    @Override
    public void handle(Job<?, ?> job, MergeRequestHook hook, boolean ciSkip, BranchFilter branchFilter, MergeRequestLabelFilter mergeRequestLabelFilter) {
        if (isAllowedByConfig(objectAttributes)
            && isLastCommitNotYetBuild(job, hook)
            && isNotSkipWorkInProgressMergeRequest(objectAttributes)) {

            List<String> labelsNames = new ArrayList<>();
            if (hook.getLabels() != null) {
                for (MergeRequestLabel label : hook.getLabels()) {
                    labelsNames.add(label.getTitle());
                }
            }

            if (mergeRequestLabelFilter.isMergeRequestAllowed(labelsNames)) {
                super.handle(job, hook, ciSkip, branchFilter, mergeRequestLabelFilter);
            }
        }

    private boolean isAllowedByConfig(MergeRequestObjectAttributes objectAttributes) {
		return triggerConfig.apply(objectAttributes);
    }
}
public class TriggerConfigChain implements Predicate<MergeRequestObjectAttributes> {
    @Override
    public boolean apply(@Nullable MergeRequestObjectAttributes mergeRequestObjectAttributes) {
        for (Predicate<MergeRequestObjectAttributes> predicate : rejectRules) {
            if (predicate.apply(mergeRequestObjectAttributes)) {
                return false;
            }
        }

        for (Predicate<MergeRequestObjectAttributes> predicate : acceptRules) {
            if (predicate.apply(mergeRequestObjectAttributes)) {
                return true;
            }
        }
        return false;
    }
}
class StateAndActionConfig implements Predicate<MergeRequestObjectAttributes> {
    private final Predicate<State> states;
    private final Predicate<Action> actions;
    ...
    static <T> Predicate<T> nullOrContains(final Collection<T> collection) {
        return collection == null ? Predicates.<T>alwaysTrue() : new Predicate<T>() {
            @Override
            public boolean apply(@Nullable T t) {
                return t == null || collection.contains(t);
            }
        };
    }
   ...
}

I guess that, if we can re-correct Action enum by change from closed to close, the problem will be resolved.

@sniiick
Copy link

sniiick commented Apr 2, 2019

@haminhcong You are absolutely right.
Also manually changing the request from action "close" to "closed" doesn't work due to isLastCommitNotYetBuild check.

com.dabsquared.gitlabjenkins.trigger.handler.merge.MergeRequestHookTriggerHandlerImpl isLastCommitNotYetBuild
INFO: Last commit in Merge Request has already been built in build #..

class MergeRequestHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<MergeRequestHook> implements MergeRequestHookTriggerHandler {
    @Override
    public void handle(Job<?, ?> job, MergeRequestHook hook, boolean ciSkip, BranchFilter branchFilter, MergeRequestLabelFilter mergeRequestLabelFilter) {
        if (isAllowedByConfig(objectAttributes)
            && isLastCommitNotYetBuild(job, hook)
            && isNotSkipWorkInProgressMergeRequest(objectAttributes)) {

            List<String> labelsNames = new ArrayList<>();
            if (hook.getLabels() != null) {
                for (MergeRequestLabel label : hook.getLabels()) {
                    labelsNames.add(label.getTitle());
                }
            }

            if (mergeRequestLabelFilter.isMergeRequestAllowed(labelsNames)) {
                super.handle(job, hook, ciSkip, branchFilter, mergeRequestLabelFilter);
            }
        }

    private boolean isAllowedByConfig(MergeRequestObjectAttributes objectAttributes) {
		return triggerConfig.apply(objectAttributes);
    }
}

@haminhcong
Copy link
Author

haminhcong commented Apr 3, 2019

@snicks92 I don't need isLastCommitNotYetBuild feature in my Jenkins system, so in my private fork i disabled this check and build this plugin from modified source :)

    @Override
    public void handle(Job<?, ?> job, MergeRequestHook hook, boolean ciSkip, BranchFilter branchFilter, MergeRequestLabelFilter mergeRequestLabelFilter) {
        MergeRequestObjectAttributes objectAttributes = hook.getObjectAttributes();
        if (isAllowedByConfig(objectAttributes)
            && isNotSkipWorkInProgressMergeRequest(objectAttributes)) {

            List<String> labelsNames = new ArrayList<>();
            if (hook.getLabels() != null) {
                for (MergeRequestLabel label : hook.getLabels()) {
                    labelsNames.add(label.getTitle());
                }
            }

            if (mergeRequestLabelFilter.isMergeRequestAllowed(labelsNames)) {
                super.handle(job, hook, ciSkip, branchFilter, mergeRequestLabelFilter);
            }
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants