修复git仓库与触发仓库不一致导致构建失败的问题
This commit is contained in:
parent
d0a31c7261
commit
ea04e83e7a
|
@ -84,26 +84,11 @@ public abstract class AbstractWebHookTriggerHandler<H extends WebHook> implement
|
|||
|
||||
protected abstract BuildStatusUpdate retrieveBuildStatusUpdate(H hook);
|
||||
|
||||
protected URIish retrieveUrIish(WebHook hook, GitSCM gitSCM) {
|
||||
if (gitSCM == null) {
|
||||
return null;
|
||||
}
|
||||
List<URIish> uris = new ArrayList<URIish>();
|
||||
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");
|
||||
|
|
|
@ -125,7 +125,7 @@ class NoteHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<NoteHook>
|
|||
|
||||
@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
|
||||
|
|
|
@ -131,7 +131,7 @@ class PipelineHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<Pipel
|
|||
|
||||
@Override
|
||||
protected RevisionParameterAction createRevisionParameter(PipelineHook hook, GitSCM gitSCM) throws NoRevisionToBuildException {
|
||||
return new RevisionParameterAction(retrieveRevisionToBuild(hook), retrieveUrIish(hook, gitSCM));
|
||||
return new RevisionParameterAction(retrieveRevisionToBuild(hook), retrieveUrIish(hook));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -189,7 +189,7 @@ class PullRequestHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<Pu
|
|||
|
||||
@Override
|
||||
protected RevisionParameterAction createRevisionParameter(PullRequestHook hook, GitSCM gitSCM) throws NoRevisionToBuildException {
|
||||
return new RevisionParameterAction(retrieveRevisionToBuild(hook), retrieveUrIish(hook, gitSCM));
|
||||
return new RevisionParameterAction(retrieveRevisionToBuild(hook), retrieveUrIish(hook));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -115,7 +115,7 @@ class PushHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler<PushHook>
|
|||
|
||||
@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
|
||||
|
|
Loading…
Reference in New Issue