diff --git a/plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/replay/ReplayAction.java b/plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/replay/ReplayAction.java index 67ecdde74..b4fd25515 100644 --- a/plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/replay/ReplayAction.java +++ b/plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/replay/ReplayAction.java @@ -141,6 +141,7 @@ public String getUrlName() { return null; } + /** Offer a fallback Rebuild link if Replay is not permitted? */ /* accessible to Jelly */ public boolean isRebuildEnabled() { if (!run.hasPermission(Item.BUILD)) { return false; @@ -148,6 +149,27 @@ public String getUrlName() { if (!run.getParent().isBuildable()) { return false; } + if (Jenkins.get().getPlugin("rebuild") != null) { + // Go via reflection to avoid a pom.xml (and subsequent + // Jenkins controller) dependency on the "competing" plugin: + try { + Class abstractRebuildAction = Jenkins.get() + .getPluginManager() + .uberClassLoader + .loadClass("com.sonyericsson.rebuild.AbstractRebuildAction"); + if ((Boolean) + abstractRebuildAction.getMethod("isRebuildAvailable").invoke(null)) { + // THAT plugin will handle the Rebuild link better + // (parameterized if need be), so we here should + // show nothing at all + return false; + } + } catch (ClassNotFoundException e) { + // ignore + } catch (Exception e) { + LOGGER.log(Level.WARNING, "failed to check for rebuild-plugin", e); + } + } return true; } diff --git a/plugin/src/main/resources/org/jenkinsci/plugins/workflow/cps/replay/ReplayAction/index.jelly b/plugin/src/main/resources/org/jenkinsci/plugins/workflow/cps/replay/ReplayAction/index.jelly index c4730f327..819cb0555 100644 --- a/plugin/src/main/resources/org/jenkinsci/plugins/workflow/cps/replay/ReplayAction/index.jelly +++ b/plugin/src/main/resources/org/jenkinsci/plugins/workflow/cps/replay/ReplayAction/index.jelly @@ -29,15 +29,17 @@ -

${%Rebuild(it.owner.displayName)}

-

- -

- - - - - + +

${%Rebuild(it.owner.displayName)}

+

+ +

+ + + + + +