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 6b637b4..90dde69 100644 --- a/src/main/java/com/gitee/jenkins/trigger/handler/AbstractWebHookTriggerHandler.java +++ b/src/main/java/com/gitee/jenkins/trigger/handler/AbstractWebHookTriggerHandler.java @@ -89,16 +89,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 8b1d527..2399973 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 @@ -213,9 +213,13 @@ class NoteHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler } private String retrieveRevisionToBuild(NoteHook hook) throws NoRevisionToBuildException { - if (hook.getPullRequest() != null - && hook.getPullRequest().getMergeReferenceName() != null) { - return hook.getPullRequest().getMergeReferenceName(); + if (hook.getPullRequest() != null) { + if (hook.getPullRequest().getMergeCommitSha() != null) { + return hook.getPullRequest().getMergeCommitSha(); + } + if (hook.getPullRequest().getMergeReferenceName() != null) { + return hook.getPullRequest().getMergeReferenceName(); + } } // 兼容来自commit的评论 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 d3f771c..4718f66 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 @@ -246,12 +246,15 @@ class PullRequestHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler mergeBuild) {