From ea04e83e7a3c9cef85b531af79a570766acedd22 Mon Sep 17 00:00:00 2001 From: yashin Date: Wed, 5 Aug 2020 12:01:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dgit=E4=BB=93=E5=BA=93?= =?UTF-8?q?=E4=B8=8E=E8=A7=A6=E5=8F=91=E4=BB=93=E5=BA=93=E4=B8=8D=E4=B8=80?= =?UTF-8?q?=E8=87=B4=E5=AF=BC=E8=87=B4=E6=9E=84=E5=BB=BA=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractWebHookTriggerHandler.java | 21 +++---------------- .../note/NoteHookTriggerHandlerImpl.java | 2 +- .../PipelineHookTriggerHandlerImpl.java | 2 +- .../PullRequestHookTriggerHandlerImpl.java | 2 +- .../push/PushHookTriggerHandlerImpl.java | 2 +- 5 files changed, 7 insertions(+), 22 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..20e707f 100644 --- a/src/main/java/com/gitee/jenkins/trigger/handler/AbstractWebHookTriggerHandler.java +++ b/src/main/java/com/gitee/jenkins/trigger/handler/AbstractWebHookTriggerHandler.java @@ -84,26 +84,11 @@ public abstract class AbstractWebHookTriggerHandler implement protected abstract BuildStatusUpdate retrieveBuildStatusUpdate(H hook); - protected URIish retrieveUrIish(WebHook hook, GitSCM gitSCM) { - if (gitSCM == null) { - return null; - } - List uris = new ArrayList(); + protected URIish retrieveUrIish(WebHook hook) { + 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())); - } - // uri 需与当前项目仓库个url一致,避免触发多个构建 - for (RemoteConfig remote : gitSCM.getRepositories()) { - for (URIish remoteURL : remote.getURIs()) { - for (URIish uri : uris) { - if (remoteURL.equals(uri)) { - return uri; - } - } - } + return new URIish(hook.getRepository().getUrl()); } } catch (URISyntaxException e) { LOGGER.log(Level.WARNING, "could not parse URL"); 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..44cb549 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 @@ -125,7 +125,7 @@ class NoteHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler @Override protected RevisionParameterAction createRevisionParameter(NoteHook hook, GitSCM gitSCM) throws NoRevisionToBuildException { - return new RevisionParameterAction(retrieveRevisionToBuild(hook), retrieveUrIish(hook, gitSCM)); + return new RevisionParameterAction(retrieveRevisionToBuild(hook), retrieveUrIish(hook)); } @Override diff --git a/src/main/java/com/gitee/jenkins/trigger/handler/pipeline/PipelineHookTriggerHandlerImpl.java b/src/main/java/com/gitee/jenkins/trigger/handler/pipeline/PipelineHookTriggerHandlerImpl.java index 69bb084..b78f069 100644 --- a/src/main/java/com/gitee/jenkins/trigger/handler/pipeline/PipelineHookTriggerHandlerImpl.java +++ b/src/main/java/com/gitee/jenkins/trigger/handler/pipeline/PipelineHookTriggerHandlerImpl.java @@ -131,7 +131,7 @@ class PipelineHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler @Override protected RevisionParameterAction createRevisionParameter(PushHook hook, GitSCM gitSCM) throws NoRevisionToBuildException { - return new RevisionParameterAction(retrieveRevisionToBuild(hook, gitSCM), retrieveUrIish(hook, gitSCM)); + return new RevisionParameterAction(retrieveRevisionToBuild(hook, gitSCM), retrieveUrIish(hook)); } @Override