Skip to content

Commit

Permalink
Test with Java 21 (#1002)
Browse files Browse the repository at this point in the history
* Remove Java 8 test support

No longer support Java 8

* Run one test per core on ci.jenkins.io

Faster tests are less expensive and pass for me.

* Test with Java 21

* Don't run parallel tests, ci.jenkins.io fails

* Remove unnecessary trailing anchor from regex

* Update a comment that mentioned Java 8

* Test Jenkins 2.401.3, not 2.414

2.414 has changed cloud naming in a way that breaks the test
  • Loading branch information
MarkEWaite committed Aug 13, 2023
1 parent a5566e4 commit ecabef3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
3 changes: 2 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ buildPlugin(
useContainerAgent: false,
// Show failures on all configurations
failFast: false,
// Test Java 11 with minimum Jenkins version, Java 17 with a more recent version
// Test Java 11, 17, and 21
configurations: [
[platform: 'linux', jdk: 17],
[platform: 'linux', jdk: '21', jenkins: '2.401.3'],
[platform: 'windows', jdk: 11],
])
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public void connectAgentViaDirectAttach() throws Exception {
@Test
public void connectAgentViaDirectAttachWithCustomCmd() throws Exception {
final DockerComputerAttachConnector connector = new DockerComputerAttachConnector(COMMON_IMAGE_USERNAME);
// We could setJavaExe("/usr/local/openjdk-8/bin/java") too, but that'd mean
// we'd break the instant that the public docker image's JVM updates to 9 or
// higher; best stick to just using the $PATH.
// We could setJavaExe("/opt/jdk-11/bin/java") too, but that'd
// mean we'd break the instant that the public docker image's JVM
// updates to a newer JDK; best stick to just using the $PATH.
connector.setJvmArgsString("-Xmx1g" + "\n" + "-Dfoo=bar\n");
connector.setEntryPointCmdString("java\n"
+ "${" + ArgumentVariables.JvmArgs.getName() + "}\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,12 @@ private static int getJavaVersion() {
final String systemPropertyName = "java.version";
final String javaVersion = System.getProperty(systemPropertyName);
try {
if (javaVersion.startsWith("1.")) {
// we're using Java 8 or lower so the syntax is 1.x where x is the version we
// want.
// ... and we know that x will be a single digit.
// e.g. 1.8.1 is Java 8, 1.6.3 is Java 6 etc.
final String secondNumber = javaVersion.substring(2, 3);
return Integer.parseInt(secondNumber);
}
// otherwise we're using Java 9 or higher so the syntax is x.n...
// We're using Java 9 or higher so the syntax is x.n...
// ... but x might be multiple digits.
// e.g. 9.0 is Java 9, 11.123.4 is Java 11 etc.
// Early access builds report as "21-ea". Remove all text after "-".
final int indexOfPeriod = javaVersion.indexOf('.');
final String firstNumber = indexOfPeriod < 0 ? javaVersion : javaVersion.substring(0, indexOfPeriod);
final String firstNumber = javaVersion.replaceAll("[-.].*", "");
return Integer.parseInt(firstNumber);
} catch (RuntimeException ex) {
throw new IllegalStateException(
Expand Down

0 comments on commit ecabef3

Please sign in to comment.