Skip to content
Open
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
51 changes: 37 additions & 14 deletions src/main/java/hudson/plugins/ec2/ssh/EC2UnixLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -277,20 +277,43 @@ protected void launchScript(EC2Computer computer, TaskListener listener)
}
}

executeRemote(
computer,
clientSession,
javaPath + " -fullversion",
"sudo amazon-linux-extras install java-openjdk11 -y; sudo yum install -y fontconfig java-11-openjdk",
logger,
listener);
executeRemote(
computer,
clientSession,
"which scp",
"sudo yum install -y openssh-clients",
logger,
listener);
if (executeRemote(clientSession, "which yum", logger)) {
logInfo(computer, listener, "Using yum as package manager...");

executeRemote(
computer,
clientSession,
javaPath + " -fullversion",
"sudo amazon-linux-extras install java-openjdk11 -y; sudo yum install -y fontconfig java-11-openjdk",
logger,
listener);
executeRemote(
computer,
clientSession,
"which scp",
"sudo yum install -y openssh-clients",
logger,
listener);

}

if (executeRemote(clientSession, "which apt", logger)) {
logInfo(computer, listener, "Using apt as package manager...");
executeRemote(
computer,
clientSession,
javaPath + " -fullversion",
"apt install -y --no-install-recommends fontconfig openjdk-11-jdk-headless",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Java 17 is the minimum required (21 recommended), so there is no way this could work. Which leads me to think that the Yum variant has not actually worked for a long time either, and nobody noticed because nobody was using this system. Nor should you. Installing Java at runtime forces every agent launch to take much longer, and abuses the bandwidth offered for free by Linux distro servers. 45bae19 was a bad idea, #245 made it worse, #246 compounded the bad idea, and #777 perpetuated it. Since the existing code does not work, it would be better to just delete it and not pretend.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(If you want to play with the plugin without going to the bother of creating your own AMI, you can already install a Java package using the init script. But you should never do this in a production system or at scale.)

logger,
listener);
executeRemote(
computer,
clientSession,
"which scp",
"sudo apt install -y openssh-client",
logger,
listener);
}

// Always copy so we get the most recent remoting.jar
logInfo(computer, listener, "Copying remoting.jar to: " + tmpDir);
Expand Down