Skip to content

Commit 217b293

Browse files
MarkEWaiteoleg-nenashev
authored andcommitted
[JENKINS-52282] Add isJavaWebStartSupported to JNLPLauncher (#3766)
* [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
1 parent b0d1501 commit 217b293

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

core/src/main/java/hudson/slaves/JNLPLauncher.java

+15
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,19 @@ public boolean filterType(@Nonnull Class<?> contextClass, @Nonnull Descriptor de
221221
}
222222
}
223223

224+
/**
225+
* Returns true if Java Web Start button should be displayed.
226+
* Java Web Start is only supported when the Jenkins server is
227+
* running with Java 8. Earlier Java versions are not supported by Jenkins.
228+
* Later Java versions do not support Java Web Start.
229+
*
230+
* This flag is checked in {@code config.jelly} before displaying the
231+
* Java Web Start button.
232+
* @return {@code true} if Java Web Start button should be displayed.
233+
* @since FIXME
234+
*/
235+
@Restricted(NoExternalUse.class) // Jelly use
236+
public boolean isJavaWebStartSupported() {
237+
return System.getProperty("java.version", "1.8").startsWith("1.8");
238+
}
224239
}

core/src/main/resources/hudson/slaves/JNLPLauncher/main.jelly

+21-8
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,27 @@ THE SOFTWARE.
3737
${%Connect agent to Jenkins one of these ways:}
3838
</p>
3939
<ul>
40-
<li>
41-
<p>
42-
<a href="slave-agent.jnlp" id="jnlp-link">
43-
<img src="${imagesURL}/webstart.gif" alt="${%launch agent}" />
44-
</a>
45-
${%Launch agent from browser}
46-
</p>
47-
</li>
40+
<j:choose>
41+
<j:when test="${it.launcher.javaWebStartSupported}">
42+
<li>
43+
<p>
44+
<a href="slave-agent.jnlp" id="jnlp-link">
45+
<img src="${imagesURL}/webstart.gif" alt="${%launch agent}" />
46+
</a>
47+
${%Launch agent from browser}
48+
</p>
49+
</li>
50+
</j:when>
51+
<j:otherwise>
52+
<li>
53+
<p>
54+
<a href="https://jenkins.io/redirect/java11-java-web-start">
55+
${%Java Web Start is not available for the JVM version running Jenkins}
56+
</a>
57+
</p>
58+
</li>
59+
</j:otherwise>
60+
</j:choose>
4861
<j:choose>
4962
<j:when test="${it.ACL.hasPermission(app.ANONYMOUS, it.CONNECT)}">
5063
<li>

0 commit comments

Comments
 (0)