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 [ ]

$ 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) unexpected stream termination at hudson.remoting.ChannelBuilder.negotiate( at at hudson.slaves.SlaveComputer.setChannel( at hudson.slaves.CommandLauncher.launch( at hudson.plugins.ec2.ssh.EC2UnixLauncher.launchScript( at hudson.plugins.ec2.EC2ComputerLauncher.launch( at hudson.slaves.SlaveComputer.lambda$_connect$0( at jenkins.util.ContextResettingExecutorService$ at$ at at java.util.concurrent.ThreadPoolExecutor.runWorker( at java.util.concurrent.ThreadPoolExecutor$ at