Skip to content

Commit

Permalink
[JENKINS-52282] Add isJavaWebStartSupported to JNLPLauncher (#3766)
Browse files Browse the repository at this point in the history
* [JENKINS-52282] Add isJavaWebStartSupported to JNLPLauncher

Seems cleaner to use JNLPLauncher than to use Functions.  Narrows the
scope of the method so that callers know it is specific to
JNLPLauncher.

* Include hyperlink to jenkins.io Java Web Start redirect page
  • Loading branch information
MarkEWaite authored and oleg-nenashev committed Nov 24, 2018
1 parent b0d1501 commit 217b293
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
15 changes: 15 additions & 0 deletions core/src/main/java/hudson/slaves/JNLPLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,19 @@ public boolean filterType(@Nonnull Class<?> contextClass, @Nonnull Descriptor de
}
}

/**
* Returns true if Java Web Start button should be displayed.
* Java Web Start is only supported when the Jenkins server is
* running with Java 8. Earlier Java versions are not supported by Jenkins.
* Later Java versions do not support Java Web Start.
*
* This flag is checked in {@code config.jelly} before displaying the
* Java Web Start button.
* @return {@code true} if Java Web Start button should be displayed.
* @since FIXME
*/
@Restricted(NoExternalUse.class) // Jelly use
public boolean isJavaWebStartSupported() {
return System.getProperty("java.version", "1.8").startsWith("1.8");
}
}
29 changes: 21 additions & 8 deletions core/src/main/resources/hudson/slaves/JNLPLauncher/main.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,27 @@ THE SOFTWARE.
${%Connect agent to Jenkins one of these ways:}
</p>
<ul>
<li>
<p>
<a href="slave-agent.jnlp" id="jnlp-link">
<img src="${imagesURL}/webstart.gif" alt="${%launch agent}" />
</a>
${%Launch agent from browser}
</p>
</li>
<j:choose>
<j:when test="${it.launcher.javaWebStartSupported}">
<li>
<p>
<a href="slave-agent.jnlp" id="jnlp-link">
<img src="${imagesURL}/webstart.gif" alt="${%launch agent}" />
</a>
${%Launch agent from browser}
</p>
</li>
</j:when>
<j:otherwise>
<li>
<p>
<a href="https://jenkins.io/redirect/java11-java-web-start">
${%Java Web Start is not available for the JVM version running Jenkins}
</a>
</p>
</li>
</j:otherwise>
</j:choose>
<j:choose>
<j:when test="${it.ACL.hasPermission(app.ANONYMOUS, it.CONNECT)}">
<li>
Expand Down

0 comments on commit 217b293

Please sign in to comment.