From 4b67166d50897c57900060024f778ba51d1d130f Mon Sep 17 00:00:00 2001 From: Guixian Zhang Date: Tue, 29 Dec 2020 18:34:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8D=E5=90=8CWebHook?= =?UTF-8?q?=E7=9B=B8=E5=90=8C=E5=BA=8F=E5=8F=B7=E7=9A=84=20PR=20=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=EF=BC=8C=E5=B9=B6=E5=8F=91=E8=A7=A6=E5=8F=91=E7=9A=84?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E8=A2=AB=E5=88=A4=E6=96=AD=E4=B8=BA=E7=9B=B8?= =?UTF-8?q?=E5=90=8C=E6=9E=84=E5=BB=BA=E5=8F=96=E6=B6=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/AbstractWebHookTriggerHandler.java | 13 +++++++------ .../handler/note/NoteHookTriggerHandlerImpl.java | 4 ++-- .../pull/PullRequestHookTriggerHandlerImpl.java | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/gitee/jenkins/trigger/handler/AbstractWebHookTriggerHandler.java b/src/main/java/com/gitee/jenkins/trigger/handler/AbstractWebHookTriggerHandler.java index 096628a..28d6576 100644 --- a/src/main/java/com/gitee/jenkins/trigger/handler/AbstractWebHookTriggerHandler.java +++ b/src/main/java/com/gitee/jenkins/trigger/handler/AbstractWebHookTriggerHandler.java @@ -85,16 +85,17 @@ public abstract class AbstractWebHookTriggerHandler implement protected abstract BuildStatusUpdate retrieveBuildStatusUpdate(H hook); protected URIish retrieveUrIish(WebHook hook, GitSCM gitSCM) { - if (gitSCM == null) { + if (hook.getRepository() == null) { return null; } - List uris = new ArrayList(); try { - if (hook.getRepository() != null) { - uris.add(new URIish(hook.getRepository().getUrl())); - uris.add(new URIish(hook.getRepository().getGitHttpUrl())); - uris.add(new URIish(hook.getRepository().getGitSshUrl())); + if (gitSCM == null) { + return new URIish(hook.getRepository().getGitHttpUrl()); } + List uris = new ArrayList(); + uris.add(new URIish(hook.getRepository().getUrl())); + uris.add(new URIish(hook.getRepository().getGitHttpUrl())); + uris.add(new URIish(hook.getRepository().getGitSshUrl())); // uri 需与当前项目仓库个url一致,避免触发多个构建 for (RemoteConfig remote : gitSCM.getRepositories()) { for (URIish remoteURL : remote.getURIs()) { diff --git a/src/main/java/com/gitee/jenkins/trigger/handler/note/NoteHookTriggerHandlerImpl.java b/src/main/java/com/gitee/jenkins/trigger/handler/note/NoteHookTriggerHandlerImpl.java index a57f4e6..e8ce65c 100644 --- a/src/main/java/com/gitee/jenkins/trigger/handler/note/NoteHookTriggerHandlerImpl.java +++ b/src/main/java/com/gitee/jenkins/trigger/handler/note/NoteHookTriggerHandlerImpl.java @@ -139,8 +139,8 @@ class NoteHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler private String retrieveRevisionToBuild(NoteHook hook) throws NoRevisionToBuildException { if (hook.getPullRequest() != null - && hook.getPullRequest().getMergeReferenceName() != null) { - return hook.getPullRequest().getMergeReferenceName(); + && hook.getPullRequest().getMergeCommitSha() != null) { + return hook.getPullRequest().getMergeCommitSha(); } else { throw new NoRevisionToBuildException(); } diff --git a/src/main/java/com/gitee/jenkins/trigger/handler/pull/PullRequestHookTriggerHandlerImpl.java b/src/main/java/com/gitee/jenkins/trigger/handler/pull/PullRequestHookTriggerHandlerImpl.java index 54271e2..a91d985 100644 --- a/src/main/java/com/gitee/jenkins/trigger/handler/pull/PullRequestHookTriggerHandlerImpl.java +++ b/src/main/java/com/gitee/jenkins/trigger/handler/pull/PullRequestHookTriggerHandlerImpl.java @@ -203,8 +203,8 @@ class PullRequestHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler