bash: java: command not found ERROR: Unable to launch the agent for EC2 (AWS) -

We have a native Cloud configuration for our slaves ( Ubuntu 20.04 ). We are self provisioning with a cloud script ( Installing Java JVM ).

While Jenkins master connects to the slaves, it detects that java is not installed and it crashes. But if we manually hit the “re-launch agent” button after the cloud-init script is done as when the java has been installed then its works fine.

What we are expecting here is, it shouldn’t crashes instead keep trying to connect to the slave like after 1 min, maybe 30 sec or till then it detects java installation

We are trying this steps to configuring slaves for Jenkins

  • We’re using Ubuntu base images ( 20.04 )
  • Java is not installed by default but we’re installing it via cloud-init scripts ( Java version 8 )
  • If we click on “re-launch slave” after the cloud-init script is done, it’s working fine.

the plugin is the EC2 plugin [ https://plugins.jenkins.io/ec2/ ]

$ ssh -o StrictHostKeyChecking=no -i /tmp/file.pem ubuntu@ -p 22 java -jar /tmp/remoting.jar -workDir /home/ubuntu Warning: Permanently added ‘’ (ECDSA) to the list of known hosts. bash: java: command not found ERROR: Unable to launch the agent for EC2 (AWS) - CI Worker (i-09a5d4d5a6da6c01e) java.io.EOFException: unexpected stream termination at hudson.remoting.ChannelBuilder.negotiate(ChannelBuilder.java:415) at hudson.remoting.ChannelBuilder.build(ChannelBuilder.java:360) at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:426) at hudson.slaves.CommandLauncher.launch(CommandLauncher.java:165) at hudson.plugins.ec2.ssh.EC2UnixLauncher.launchScript(EC2UnixLauncher.java:262) at hudson.plugins.ec2.EC2ComputerLauncher.launch(EC2ComputerLauncher.java:48) at hudson.slaves.SlaveComputer.lambda$_connect$0(SlaveComputer.java:295) at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46) at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:80) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)