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