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

Installing JDK on Windows agents deletes existing Java installation and reboots agent

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Blocker Blocker
    • core, envinject-plugin
    • Jenkins 1.606.

      Jenkins Master installed on Windows Server 2008 R2.

      Jenkins Slave installed on Windows Server 2008 R2.

      Java version jre1.8.0_40 on Jenkins Slave.

      First of all, I know there are other tickets dealing with the same issue, but they seem to have been fixed in the latest Jenkins version. But in my case, the issue still remains...

      I've first created a Windows Agent Service with the slave-agent.jnlp. After this step, the controller could succesfully connect to the Windows agent. Windows agent is also a Windows Server 2008 R2.

      To install the agent as a service, I had to install Java Jre. Did the installation in C:\jenkins_opt\Java\jre1.8.0_40. The Windows Agent Service directory is C:\jenkins_slave.

      Then I launched a Jenkins project on the Agent Node. Jenkins first tries to install a Java jdk in the tools directory. For some reason this doesn't seem to work. What happens is that the installation in C:\jenkins_opt\Java\jre1.8.0_40 is deleted and the Windows Agent is rebooted.

      After restart, Java installation in C:\jenkins_opt\Java\jre1.8.0_40 is gone and no installation of Java Jdk is done in C:\jenkins_slave\tools\hudson.model.JDK\JDK8u40.

      The install...log file in C:\jenkins_slave\tools\hudson.model.JDK is empty.

      -------------------------------------------------------------------------------

      Console output of Controller Jenkins project:

      00:00:00.006 Started by user Lieven Cardoen
      00:00:00.008 [EnvInject] - Loading node environment variables.
      00:00:23.581 Installing C:\jenkins_slave\tools\hudson.model.JDK\JDK8u40\jdk.exe
      00:00:23.916 [JDK8u40] $ C:\jenkins_slave\tools\hudson.model.JDK\JDK8u40\jdk.exe /s ADDLOCAL="ToolsFeature" REBOOT=ReallySuppress INSTALLDIR=C:\jenkins_slave\tools\hudson.model.JDK\JDK8u40 /L C:\jenkins_slave\tools\hudson.model.JDK\install3674831485415202650log
      00:00:36.081 Failed to install JDK. Exit code=-1
      00:00:36.110 ERROR: SEVERE ERROR occurs
      00:00:36.111 org.jenkinsci.lib.envinject.EnvInjectException: hudson.AbortException
      00:00:36.111 at org.jenkinsci.plugins.envinject.service.EnvInjectVariableGetter.getBuildVariables(EnvInjectVariableGetter.java:91)
      00:00:36.111 at org.jenkinsci.plugins.envinject.EnvInjectListener.setUpEnvironmentWithoutJobPropertyObject(EnvInjectListener.java:231)
      00:00:36.111 at org.jenkinsci.plugins.envinject.EnvInjectListener.setUpEnvironment(EnvInjectListener.java:46)
      00:00:36.111 at hudson.model.AbstractBuild$AbstractBuildExecution.createLauncher(AbstractBuild.java:574)
      00:00:36.111 at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:494)
      00:00:36.111 at hudson.model.Run.execute(Run.java:1751)
      00:00:36.111 at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      00:00:36.111 at hudson.model.ResourceController.execute(ResourceController.java:89)
      00:00:36.111 at hudson.model.Executor.run(Executor.java:240)
      00:00:36.111 Caused by: hudson.AbortException
      00:00:36.111 at hudson.tools.JDKInstaller.install(JDKInstaller.java:279)
      00:00:36.111 at hudson.tools.JDKInstaller.performInstallation(JDKInstaller.java:141)
      00:00:36.112 at hudson.tools.InstallerTranslator.getToolHome(InstallerTranslator.java:68)
      00:00:36.112 at hudson.tools.ToolLocationNodeProperty.getToolHome(ToolLocationNodeProperty.java:107)
      00:00:36.112 at hudson.tools.ToolInstallation.translateFor(ToolInstallation.java:205)
      00:00:36.112 at hudson.model.JDK.forNode(JDK.java:130)
      00:00:36.112 at org.jenkinsci.plugins.envinject.service.EnvInjectVariableGetter.getBuildVariables(EnvInjectVariableGetter.java:86)
      00:00:36.112 ... 8 more
      00:00:36.112
      00:00:36.112 Deleting project workspace...
      00:00:36.116 Notifying upstream projects of job completion
      00:00:36.116 Finished: FAILURE

      -------------------------------------------------------------------------------

      To get my Agent up and running again, I need to re-install the JRE again (because Jenkins wiped it) and restart the Windows Service. Triggering the Jenkins Job will wip the JRE again and reboot the Windows Agent.

      On one of the Windows Agent, after trying a couple of times, suddenly it did work. But I have no idea why in that case it worked. Manually installing the jdk in the tools directory does work. If after installing it manually I trigger the Jenkins project again, then I tries to install the JDK again, and now it does work...

      Now in the C:\jenkins_slave\tools\hudson.model.JDK\JDK8u40 there's a .installedByHudson file.

      Maybe that the manual install changed a JAVA_HOME environment variable?

      -------------------------------------------------------------------------------

      Console output Controller of the succeeded build:

      00:00:00.006 Started by user Lieven Cardoen
      00:00:00.009 [EnvInject] - Loading node environment variables.
      00:00:13.086 Installing C:\jenkins_slave\tools\hudson.model.JDK\JDK8u40\jdk.exe
      00:00:18.730 [JDK8u40] $ C:\jenkins_slave\tools\hudson.model.JDK\JDK8u40\jdk.exe /s ADDLOCAL="ToolsFeature" REBOOT=ReallySuppress INSTALLDIR=C:\jenkins_slave\tools\hudson.model.JDK\JDK8u40 /L C:\jenkins_slave\tools\hudson.model.JDK\install7252311317026251390log
      00:00:52.494 Building remotely on SRV-DEV-GPRO-HYP in workspace C:\jenkins_slave\workspace\SRV-DEV-GPRO-HYP-DEPLOY
      00:00:52.495
      00:00:52.495 Deleting project workspace... Cloning the remote Git repository
      00:00:57.031 remote: Counting objects
      00:00:57.147 remote: Finding sources
      00:00:57.468 remote: Getting sizes
      00:00:57.648 Receiving objects
      00:01:04.024 Resolving deltas
      00:01:07.916 Updating references
      00:01:09.244 Checking out Revision 3b887542dc56ae039098da9648f0839ebecf37d6 (refs/remotes/origin/master)
      00:01:20.734 First time build. Skipping changelog.
      00:01:22.188
      00:01:22.188 Deleting project workspace...
      00:01:22.225 done
      00:01:22.225
      00:01:22.227 Notifying upstream projects of job completion
      00:01:22.228 Finished: SUCCESS

      The log file seems to have vanished... install7252311317026251390log is nowhere to be found.

      If you need more log files, information, ... please let me know. I can reproduce this every single time on multiple Windows Agents.

      Kind regards, Lieven Cardoen

          [JENKINS-27616] Installing JDK on Windows agents deletes existing Java installation and reboots agent

          Daniel Beck added a comment -

          Does the issue also appear when you disable the Env-Inject plugin?

          Daniel Beck added a comment - Does the issue also appear when you disable the Env-Inject plugin?

          No, issue doe not appear when I disable the Env-Inject plugin... But I do use that plugin, so what are the next steps? Strange that the plugin messes up core functionality...

          Kind regards, Lieven Cardoen

          Lieven Cardoen added a comment - No, issue doe not appear when I disable the Env-Inject plugin... But I do use that plugin, so what are the next steps? Strange that the plugin messes up core functionality... Kind regards, Lieven Cardoen

          Daniel Beck added a comment -

          Adding env-inject component.

          If you could test whether this issue occurs on Jenkins 1.599, that would be helpful. 1.600 included a change to environment variable handling that is believed to have been fixed, but confirmation would be helpful.

          Daniel Beck added a comment - Adding env-inject component. If you could test whether this issue occurs on Jenkins 1.599, that would be helpful. 1.600 included a change to environment variable handling that is believed to have been fixed, but confirmation would be helpful.

          The issue also occurred on a version previous to 1.599, but I can't say which one it was. I'm certain it was a 1.59x version.

          Now I'm on 1.606.

          Lieven Cardoen added a comment - The issue also occurred on a version previous to 1.599, but I can't say which one it was. I'm certain it was a 1.59x version. Now I'm on 1.606.

          Kyle Lieber added a comment -

          I'm also seeing this same issue. I'm using version 1.596.2 of Jenkins with version 1.91.1 of the Env-Inject plugin.

          Kyle Lieber added a comment - I'm also seeing this same issue. I'm using version 1.596.2 of Jenkins with version 1.91.1 of the Env-Inject plugin.

          I observed this with 1.614 and 1.617.

          youri bonnaffe added a comment - I observed this with 1.614 and 1.617.

          J.F Barranco added a comment -

          Using your log as example:

          $ C:\jenkins_slave\tools\hudson.model.JDK\JDK8u40\jdk.exe /s ADDLOCAL="ToolsFeature" REBOOT=ReallySuppress INSTALLDIR=C:\jenkins_slave\tools\hudson.model.JDK\JDK8u40 /L C:\jenkins_slave\tools\hudson.model.JDK\install3674831485415202650log

          Jenkins installs JDK in Windows Slaves using Oracle windows installer in /tools/hudson.model.JDK (that jdk.exe is actually Windows Installer)

          Windows only allows ONE installation of each program version, i.e. if you have "Java SE 8u40" installed in your "C:\jenkins_opt\Java\" any try to install AGAIN same "Java SE 8u40" from Jenkins will fail because windows installer can't install it again under <JENKINS_HOME>/tools/hudson.model.JDK

          In your case you can configure a different JDK Installer version to use with your job, f.e. 8u45 . In that way windows installer won't detect a clash and Jenkins will install it under your C:\jenkins_slave\tools\hudson.model.JDK\JDK8u45

           

          J.F Barranco added a comment - Using your log as example: $ C:\jenkins_slave\tools\hudson.model.JDK\JDK8u40\jdk.exe /s ADDLOCAL= "ToolsFeature" REBOOT=ReallySuppress INSTALLDIR=C:\jenkins_slave\tools\hudson.model.JDK\JDK8u40 /L C:\jenkins_slave\tools\hudson.model.JDK\install3674831485415202650log Jenkins installs JDK in Windows Slaves using Oracle windows installer in /tools/hudson.model.JDK (that jdk.exe is actually Windows Installer) Windows only allows ONE installation of each program version, i.e. if you have "Java SE 8u40" installed in your "C:\jenkins_opt\Java\" any try to install AGAIN same "Java SE 8u40" from Jenkins will fail because windows installer can't install it again under <JENKINS_HOME>/tools/hudson.model.JDK In your case you can configure a different JDK Installer version to use with your job, f.e. 8u45 . In that way windows installer won't detect a clash and Jenkins will install it under your C:\jenkins_slave\tools\hudson.model.JDK\JDK8u45  

            gbois Gregory Boissinot
            lievencardoen Lieven Cardoen
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: