From a3bb47b2f7f5468382ca4a317705bff7e0484c72 Mon Sep 17 00:00:00 2001 From: Tom Andrews Date: Fri, 6 Nov 2015 09:59:46 +0000 Subject: [PATCH 1/3] Make ci-skip for merge requests respect option configuration --- .../com/dabsquared/gitlabjenkins/GitLabWebHook.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/dabsquared/gitlabjenkins/GitLabWebHook.java b/src/main/java/com/dabsquared/gitlabjenkins/GitLabWebHook.java index 2c3334057..f9a34d53b 100644 --- a/src/main/java/com/dabsquared/gitlabjenkins/GitLabWebHook.java +++ b/src/main/java/com/dabsquared/gitlabjenkins/GitLabWebHook.java @@ -479,10 +479,6 @@ public void generateMergeRequestBuild(String json, Job project, StaplerRequest r return; } } - if(request.getObjectAttribute().getDescription().contains("[ci-skip]")) { - LOGGER.log(Level.INFO, "Skipping MR " + request.getObjectAttribute().getTitle() + " due to ci-skip."); - return; - } Authentication old = SecurityContextHolder.getContext().getAuthentication(); SecurityContextHolder.getContext().setAuthentication(ACL.SYSTEM); @@ -499,6 +495,12 @@ public void generateMergeRequestBuild(String json, Job project, StaplerRequest r if (trigger == null) { return; } + + if(trigger.getCiSkip() && request.getObjectAttribute().getDescription().contains("[ci-skip]")) { + LOGGER.log(Level.INFO, "Skipping MR " + request.getObjectAttribute().getTitle() + " due to ci-skip."); + return; + } + trigger.onPost(request); } finally { SecurityContextHolder.getContext().setAuthentication(old); From 8eedf3dfd66f2f78b4f93f235fb95d1acbf461d6 Mon Sep 17 00:00:00 2001 From: Tom Andrews Date: Fri, 30 Oct 2015 17:31:17 +0000 Subject: [PATCH 2/3] Switch to getOpenMergeRequests api call --- src/main/java/com/dabsquared/gitlabjenkins/GitLabWebHook.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/dabsquared/gitlabjenkins/GitLabWebHook.java b/src/main/java/com/dabsquared/gitlabjenkins/GitLabWebHook.java index f9a34d53b..dede4e189 100644 --- a/src/main/java/com/dabsquared/gitlabjenkins/GitLabWebHook.java +++ b/src/main/java/com/dabsquared/gitlabjenkins/GitLabWebHook.java @@ -394,9 +394,7 @@ public void generatePushBuild(String json, Job project, StaplerRequest req, Stap protected void buildOpenMergeRequests(GitLabPushTrigger trigger, Integer projectId, String projectRef) { try { GitLab api = new GitLab(); - // TODO Replace this with a call to GitlabAPI.getOpenMergeRequests, once timols has deployed version 1.1.7 - String tailUrl = GitlabProject.URL + "/" + projectId + GitlabMergeRequest.URL + "?state=opened&per_page=100"; - List mergeRequests = api.instance().retrieve().getAll(tailUrl, GitlabMergeRequest[].class); + List mergeRequests = api.instance().getOpenMergeRequests(projectId); for (org.gitlab.api.models.GitlabMergeRequest mr : mergeRequests) { if (projectRef.endsWith(mr.getSourceBranch()) || From 6e3b157914087cf2a63e6c73d12f06c2ffe4e455 Mon Sep 17 00:00:00 2001 From: Tom Andrews Date: Fri, 30 Oct 2015 17:48:38 +0000 Subject: [PATCH 3/3] Fix logging of Author and Assignee --- src/main/java/com/dabsquared/gitlabjenkins/GitLabWebHook.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/dabsquared/gitlabjenkins/GitLabWebHook.java b/src/main/java/com/dabsquared/gitlabjenkins/GitLabWebHook.java index dede4e189..fb7b8a1a0 100644 --- a/src/main/java/com/dabsquared/gitlabjenkins/GitLabWebHook.java +++ b/src/main/java/com/dabsquared/gitlabjenkins/GitLabWebHook.java @@ -417,8 +417,8 @@ protected void buildOpenMergeRequests(GitLabPushTrigger trigger, Integer project + mr.getSourceBranch() + "\n target: " + mr.getTargetBranch() + "\n state: " + mr.getState() + "\n assign: " - + mr.getAssignee() + "\n author: " - + mr.getAuthor() + "\n id: " + + mr.getAssignee().getName() + "\n author: " + + mr.getAuthor().getName() + "\n id: " + mr.getId() + "\n iid: " + mr.getIid() + "\n last commit: " + lastCommit.getId() + "\n\n");