Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-50638

windows agent via SSH - Slave JVM has terminated. Exit code

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Major Major
    • ssh-slaves-plugin
    • ubunut x64 as master
      win10x64 as slave

      The jar file on the slave fails to start.

      I use "Launch Slave Agents via SSH"

      [04/06/18 15:32:05] [SSH] Opening SSH connection to 192.168.120.187:22.
      
      [04/06/18 15:32:06] [SSH] SSH host key matches key seen previously for this host. Connection will be allowed.
      
      [04/06/18 15:32:06] [SSH] Authentication successful.
      
      [04/06/18 15:32:06] [SSH] The remote user's environment is:
      
      [04/06/18 15:32:06] [SSH] Checking java version of java
      
      [04/06/18 15:32:06] [SSH] java -version returned 1.8.0_161.
      
      [04/06/18 15:32:06] [SSH] Starting sftp client.
      
      [04/06/18 15:32:06] [SSH] Copying latest slave.jar...
      
      [04/06/18 15:32:06] [SSH] Copied 762,466 bytes.
      
      Expanded the channel window size to 4MB
      
      [04/06/18 15:32:06] [SSH] Starting slave process: cd "D:\CI\jenkins" && java  -jar slave.jar
      
      <===[JENKINS REMOTING CAPACITY]===>Slave JVM has terminated. Exit code=0
      
      [04/06/18 15:32:06] Launch failed - cleaning up connection
      
      [04/06/18 15:32:06] [SSH] Connection closed.
      

      I use Manually trusted key Verification Strategy

      Require manual verification of initinial connection is OFF

      On windows, I use cygwin as bash, and openSSH from microsoft.

      Java version master:

      java version "1.8.0_144"
      Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
      Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
      

      Java version slave:

      java version "1.8.0_161"
      Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
      Java HotSpot(TM) Client VM (build 25.161-b12, mixed mode, sharing)
      

      The jenkins version is: Jenkins ver. 2.107.2

          [JENKINS-50638] windows agent via SSH - Slave JVM has terminated. Exit code

          >Only when I execute java.jar directly, (like you can see on the last cmd) I could start the agent, otherwise it was not returning from execution.

          That it is ok, it should not return, I wanted to check that you can execute the java -jar slave.jar and it does not return errors.

          Ivan Fernandez Calvo added a comment - >Only when I execute java.jar directly, (like you can see on the last cmd) I could start the agent, otherwise it was not returning from execution. That it is ok, it should not return, I wanted to check that you can execute the java -jar slave.jar and it does not return errors.

          The config.xml attached is a multibranch project, it is not the config.xml of the Agent, anyway add this command as suffix start label command

           || echo "KO - retcode $?"

          Then do a try an attach the output.

          Finally, replace the previous command by this one and attach the output

           && echo "OK - retcode $?"

          I want to get the real exit code of the java process

          Ivan Fernandez Calvo added a comment - The config.xml attached is a multibranch project, it is not the config.xml of the Agent, anyway add this command as suffix start label command || echo "KO - retcode $?" Then do a try an attach the output. Finally, replace the previous command by this one and attach the output && echo "OK - retcode $?" I want to get the real exit code of the java process

          How much memory has this agent? Do it has an antivirus installed?

          Ivan Fernandez Calvo added a comment - How much memory has this agent? Do it has an antivirus installed?

          Zack Snyder added a comment -

          You mean like this?

          [04/18/18 18:15:35] [SSH] Starting slave process: cd "/cygdrive/d/CI/jenkins-ssh" && java -Djava.util.logging.config.file=/cygdrive/d/CI/jenkins-ssh/logging.properties -jar slave.jar && echo "OK - retcode $?"
          <===[JENKINS REMOTING CAPACITY]===>Slave JVM has terminated. Exit code=0
          [04/18/18 18:15:35] Launch failed - cleaning up connection
          [04/18/18 18:15:35] [SSH] Connection closed.
          

          I executed the previous command before, nothing.

          The agent has 16 GB of RAM
          I can also successfully build on the machine, when I use the connection of "Launch agent via web start".

          Zack Snyder added a comment - You mean like this? [04/18/18 18:15:35] [SSH] Starting slave process: cd "/cygdrive/d/CI/jenkins-ssh" && java -Djava.util.logging.config.file=/cygdrive/d/CI/jenkins-ssh/logging.properties -jar slave.jar && echo "OK - retcode $?" <===[JENKINS REMOTING CAPACITY]===>Slave JVM has terminated. Exit code=0 [04/18/18 18:15:35] Launch failed - cleaning up connection [04/18/18 18:15:35] [SSH] Connection closed. I executed the previous command before, nothing. The agent has 16 GB of RAM I can also successfully build on the machine, when I use the connection of "Launch agent via web start".

          Zack Snyder added a comment -

          Do you not find it strange, that I could execute the slave.jar file only when I was in the folder?

          Zack Snyder added a comment - Do you not find it strange, that I could execute the slave.jar file only when I was in the folder?

          Could you try the other one? because seems like the slave.jar process die

          || echo "KO - retcode $?"

          Ivan Fernandez Calvo added a comment - Could you try the other one? because seems like the slave.jar process die || echo "KO - retcode $?"

          Ivan Fernandez Calvo added a comment - - edited

          I think that I know what happens, clean up the suffix and prefix field and put exactly this one in the prefix field

          /bin/bash -c "cd "/cygdrive/d/CI/jenkins-ssh" && java -Djava.util.logging.config.file=/cygdrive/d/CI/jenkins-ssh/logging.properties -jar slave.jar";

          Ivan Fernandez Calvo added a comment - - edited I think that I know what happens, clean up the suffix and prefix field and put exactly this one in the prefix field /bin/bash -c "cd " /cygdrive/d/CI/jenkins-ssh " && java -Djava.util.logging.config.file=/cygdrive/d/CI/jenkins-ssh/logging.properties -jar slave.jar" ;

          Zack Snyder added a comment -

          Here is the output:
          prefix_output.txt

          I just inserted text into the prefix field.

          Zack Snyder added a comment - Here is the output: prefix_output.txt I just inserted text into the prefix field.

          Zack Snyder added a comment -

          ifernandezcalvo
          Any update? Or are you now at the end of you knowledge? A tricky problem.

          Zack Snyder added a comment - ifernandezcalvo Any update? Or are you now at the end of you knowledge? A tricky problem.

           /bin/bash -c "cd "/cygdrive/d/CI/jenkins-ssh" && java -Djava.util.logging.config.file=/cygdrive/d/CI/jenkins-ssh/logging.properties -jar slave.jar"

          The command line is not correct but does not matter because "/bin/bash -c" does not return any error, it should return at least a syntax error, I do not know what happen on your environment but it is not related with the SSH Slave Plugins it is something in your sshd configuration, on your user login, on your environment initialization files (.bashrc, .profile, ...), or your default shell, I bet that if you put

          /bin/bash -c ls &&

          on your command prefix you would see nothing in the console output.
          You could try to execute a command using the ssh command line, probably it fails

          ssh USERNAME@AGENT_HOST /bin/bash -c ls

          try the same but with -t parameter, it should work

          ssh -t USERNAME@AGENT_HOST /bin/bash -c ls

          I recommend you to check a really good comment from Ben Langton at https://wiki.jenkins.io/display/JENKINS/SSH+slaves+and+Cygwin that explains all the steps that you have to make to configure OpenSSH.

          If you need more help, try in the jenkins user group.

          Ivan Fernandez Calvo added a comment - /bin/bash -c "cd " /cygdrive/d/CI/jenkins-ssh " && java -Djava.util.logging.config.file=/cygdrive/d/CI/jenkins-ssh/logging.properties -jar slave.jar" The command line is not correct but does not matter because "/bin/bash -c" does not return any error, it should return at least a syntax error, I do not know what happen on your environment but it is not related with the SSH Slave Plugins it is something in your sshd configuration, on your user login, on your environment initialization files (.bashrc, .profile, ...), or your default shell, I bet that if you put /bin/bash -c ls && on your command prefix you would see nothing in the console output. You could try to execute a command using the ssh command line, probably it fails ssh USERNAME@AGENT_HOST /bin/bash -c ls try the same but with -t parameter, it should work ssh -t USERNAME@AGENT_HOST /bin/bash -c ls I recommend you to check a really good comment from Ben Langton at https://wiki.jenkins.io/display/JENKINS/SSH+slaves+and+Cygwin that explains all the steps that you have to make to configure OpenSSH. If you need more help, try in the jenkins user group .

            ifernandezcalvo Ivan Fernandez Calvo
            zack Zack Snyder
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: