Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-52282] Add isJavaWebStartSupported to JNLPLauncher #3766

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to @since something that's @Restricted

*/
oleg-nenashev marked this conversation as resolved.
Show resolved Hide resolved
@Restricted(NoExternalUse.class) // Jelly use
public boolean isJavaWebStartSupported() {
oleg-nenashev marked this conversation as resolved.
Show resolved Hide resolved
return System.getProperty("java.version", "1.8").startsWith("1.8");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was looking for https://docs.oracle.com/javase/10/docs/api/java/lang/Runtime.Version.html but it's only available since Java 9, sadly. So I guess this startWith is really all we can do here..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I saw as well. I would have preferred a better check, but...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a hack we usually do. Probably we need to move these checks to a utility class

}
}
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