• Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • core
    • None

      Jenkins never manage to restart itself after a plugin or version update. It must always be manually restarted through the windows service manager.

      System: Windows XP
      Jenkins 1.563

      ERROR LOG:

      WARNING: Failed to restart Jenkins
      java.io.IOException: Restarting a service
      [Jenkins] $ C:\Program\Jenkins\jenkins.exe restart
      System.UnauthorizedAccessException: ?tkomst nekad. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
      at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
      at System.Management.ManagementScope.InitializeGuts(Object o)
      at System.Management.ManagementScope.Initialize()
      at System.Management.ManagementScope.Connect()
      at WMI.WmiRoot..ctor(String machineName)
      at WMI.WmiRoot..ctor()
      at winsw.WrapperService.Run(String[] _args)
      at winsw.WrapperService.Main(String[] args)

      at hudson.lifecycle.WindowsServiceLifecycle.restart(WindowsServiceLifecycle.java:138)
      at jenkins.model.Jenkins$24.run(Jenkins.java:3336)

          [JENKINS-23147] Jenkins won't restart itself through the GUI

          Hirad Asadi added a comment -

          Still not working in 1.566...

          Hirad Asadi added a comment - Still not working in 1.566...

          Daniel Beck added a comment -

          Stack trace should be different than the original above though.

          Also, what user are you running the Jenkins service as? It's not the default SYSTEM account, is it? Try to give that user permission to use WMI:

          http://technet.microsoft.com/en-us/library/cc787533%28v=WS.10%29.aspx

          Daniel Beck added a comment - Stack trace should be different than the original above though. Also, what user are you running the Jenkins service as? It's not the default SYSTEM account, is it? Try to give that user permission to use WMI: http://technet.microsoft.com/en-us/library/cc787533%28v=WS.10%29.aspx

          Hirad Asadi added a comment -

          It runs as system.

          Hirad Asadi added a comment - It runs as system.

          Kevin Phillips added a comment - - edited

          I have reproduced this same problem in the latest LTS edition (1.596.3 atm) on a clean Windows 7 x64 OS as well. I'm using Java 64bit v1.7.0_80-b15 in case that is a factor.

          I've tried setting up the Jenkins service to run under the local system account as well as a local administrative user and neither setting works correctly.

          I have confirmed that the command line interface for the service, jenkins.exe, does correctly control the Windows service. Performing "jenkins start", "jenkins stop", "jenkins restart", "jenkins uninstall" and "jenkins install" all work correctly when run from a command prompt using the same local user profile the service runs within.

          I have also tried explicitly adding WMI permissions to all relevant users / groups as well using the process found here in case this was some kind of security problem but that had no effect either.

          Finally, unlike the description above and other defects in the issue tracker like JENKINS-23395 and JENKINS-22685, I see no errors or warnings of any kind related to the service reboot. In fact the only reference to the reboot request at all in any of the logs is this short snippet I found in the jenkins.err.log file:

          Jun 01, 2015 12:10:43 PM jenkins.model.Jenkins$22 run
          SEVERE: Restarting VM as requested by anonymous

          If I try performing a "safe restart" (ie: http://jenkins/safeRestart), the results are the same but I get a couple of extra lines in the error log as shown below:

          May 26, 2015 8:41:05 AM hudson.model.UpdateCenter doSafeRestart
          INFO: Scheduling Jenkins reboot
          May 26, 2015 8:41:05 AM jenkins.model.Jenkins$23 run
          INFO: Restart in 10 seconds
          May 26, 2015 8:41:15 AM jenkins.model.Jenkins$23 run
          SEVERE: Restarting VM as requested by anonymous

          Also, after requesting the reboot, say via the http://jenkins/reboot REST call, the application does mark itself as "preparing for shutdown" but since the reboot never actually happens the service stays in this intermediate state indefinitely. You basically have to log into the server and manually for the service to restart.

          Kevin Phillips added a comment - - edited I have reproduced this same problem in the latest LTS edition (1.596.3 atm) on a clean Windows 7 x64 OS as well. I'm using Java 64bit v1.7.0_80-b15 in case that is a factor. I've tried setting up the Jenkins service to run under the local system account as well as a local administrative user and neither setting works correctly. I have confirmed that the command line interface for the service, jenkins.exe, does correctly control the Windows service. Performing "jenkins start", "jenkins stop", "jenkins restart", "jenkins uninstall" and "jenkins install" all work correctly when run from a command prompt using the same local user profile the service runs within. I have also tried explicitly adding WMI permissions to all relevant users / groups as well using the process found here in case this was some kind of security problem but that had no effect either. Finally, unlike the description above and other defects in the issue tracker like JENKINS-23395 and JENKINS-22685 , I see no errors or warnings of any kind related to the service reboot. In fact the only reference to the reboot request at all in any of the logs is this short snippet I found in the jenkins.err.log file: Jun 01, 2015 12:10:43 PM jenkins.model.Jenkins$22 run SEVERE: Restarting VM as requested by anonymous If I try performing a "safe restart" (ie: http://jenkins/safeRestart ), the results are the same but I get a couple of extra lines in the error log as shown below: May 26, 2015 8:41:05 AM hudson.model.UpdateCenter doSafeRestart INFO: Scheduling Jenkins reboot May 26, 2015 8:41:05 AM jenkins.model.Jenkins$23 run INFO: Restart in 10 seconds May 26, 2015 8:41:15 AM jenkins.model.Jenkins$23 run SEVERE: Restarting VM as requested by anonymous Also, after requesting the reboot, say via the http://jenkins/reboot REST call, the application does mark itself as "preparing for shutdown" but since the reboot never actually happens the service stays in this intermediate state indefinitely. You basically have to log into the server and manually for the service to restart.

          One other strategy I tried to work around this issue was to move the Jenkins installation folder to different locations, thinking that maybe putting it under Program Files may have caused some permission issues or something. However even if I relocate the folder to a new folder off the root partition (ie: c:\jenkins ) the same behavior ensues.

          I only mention it here just in case this helps isolate the cause of the problem.

          Kevin Phillips added a comment - One other strategy I tried to work around this issue was to move the Jenkins installation folder to different locations, thinking that maybe putting it under Program Files may have caused some permission issues or something. However even if I relocate the folder to a new folder off the root partition (ie: c:\jenkins ) the same behavior ensues. I only mention it here just in case this helps isolate the cause of the problem.

          pixman20 added a comment -

          I am also having this problem and unfortunately do not have time to debug it further at the moment.
          I had to shutdown the service and then manually kill the java.exe process before restarting the service to get Jenkins to start.
          In case it helps:
          I'm running 1.606 on Windows Server 2008 R2
          I have several slaves running via SSH (I noticed their respective java.exe processs were still running after /safeRestart)
          I have many (at least 70) different plugins activated, which may also be related to the problem if this is not occuring within a core only environment.

          pixman20 added a comment - I am also having this problem and unfortunately do not have time to debug it further at the moment. I had to shutdown the service and then manually kill the java.exe process before restarting the service to get Jenkins to start. In case it helps: I'm running 1.606 on Windows Server 2008 R2 I have several slaves running via SSH (I noticed their respective java.exe processs were still running after /safeRestart) I have many (at least 70) different plugins activated, which may also be related to the problem if this is not occuring within a core only environment.

          Rob Davies added a comment -

          I'm seeing this issue with the latest version of Jenkins (1.655); seeing the same log messages as Kevin has list above.

          I believe it worked correctly when running the service as it was initially installed under the local system account, but changing the service to run under a specified user account (needed for publishing builds to Azure) has stopped the auto-restart working.

          For the most part, restarting the service manually on the build server works, although I do occasionally need to kill the Java process as it's holding open the ports Jenkins is trying to bind to.

          For info:

          • Running a single instance; no slaves
          • Running v1.655 on Windows Server 2008 R2
          • There are ~25 non-stock plugins installed

          Rob Davies added a comment - I'm seeing this issue with the latest version of Jenkins (1.655); seeing the same log messages as Kevin has list above. I believe it worked correctly when running the service as it was initially installed under the local system account, but changing the service to run under a specified user account (needed for publishing builds to Azure) has stopped the auto-restart working. For the most part, restarting the service manually on the build server works, although I do occasionally need to kill the Java process as it's holding open the ports Jenkins is trying to bind to. For info: Running a single instance; no slaves Running v1.655 on Windows Server 2008 R2 There are ~25 non-stock plugins installed

          Grzegorz Kotarski added a comment - - edited

          I believie I'm experiencing the same issue.
          Jenkins running as windows service under specified user account.
          Restart via CLI does not work either.
          In the jenkins.err.log I can see following info:

          WARNING: Failed to restart Jenkins
          java.io.IOException: Cannot run program "D:\Jenkins\jenkins.exe" (in directory "D:\Jenkins"): CreateProcess error=87, The parameter is incorrect
          	at java.lang.ProcessBuilder.start(Unknown Source)
          	at hudson.Proc$LocalProc.<init>(Proc.java:243)
          	at hudson.Proc$LocalProc.<init>(Proc.java:212)
          	at hudson.Launcher$LocalLauncher.launch(Launcher.java:815)
          	at hudson.Launcher$ProcStarter.start(Launcher.java:381)
          	at hudson.Launcher$ProcStarter.join(Launcher.java:388)
          	at hudson.lifecycle.WindowsServiceLifecycle.restart(WindowsServiceLifecycle.java:136)
          	at jenkins.model.Jenkins$26.run(Jenkins.java:4051)
          Caused by: java.io.IOException: CreateProcess error=87, The parameter is incorrect
          	at java.lang.ProcessImpl.create(Native Method)
          	at java.lang.ProcessImpl.<init>(Unknown Source)
          	at java.lang.ProcessImpl.start(Unknown Source)
          	... 8 more
          

          The system is Windows 2008 server R2, Jenkins 2.19.3

          Grzegorz Kotarski added a comment - - edited I believie I'm experiencing the same issue. Jenkins running as windows service under specified user account. Restart via CLI does not work either. In the jenkins.err.log I can see following info: WARNING: Failed to restart Jenkins java.io.IOException: Cannot run program "D:\Jenkins\jenkins.exe" (in directory "D:\Jenkins"): CreateProcess error=87, The parameter is incorrect at java.lang.ProcessBuilder.start(Unknown Source) at hudson.Proc$LocalProc.<init>(Proc.java:243) at hudson.Proc$LocalProc.<init>(Proc.java:212) at hudson.Launcher$LocalLauncher.launch(Launcher.java:815) at hudson.Launcher$ProcStarter.start(Launcher.java:381) at hudson.Launcher$ProcStarter.join(Launcher.java:388) at hudson.lifecycle.WindowsServiceLifecycle.restart(WindowsServiceLifecycle.java:136) at jenkins.model.Jenkins$26.run(Jenkins.java:4051) Caused by: java.io.IOException: CreateProcess error=87, The parameter is incorrect at java.lang.ProcessImpl.create(Native Method) at java.lang.ProcessImpl.<init>(Unknown Source) at java.lang.ProcessImpl.start(Unknown Source) ... 8 more The system is Windows 2008 server R2, Jenkins 2.19.3

          Niels Kristian Jensen added a comment - - edited

          SOLVED: On Jenkins Jenkins 2.249.3 running on Windows Server 2019, I had the same issue and fixed it by adding this access right to the jenkins install dir: "Everyone: read & execute"

          It turned out not to work always. We then saw the issue https://issues.jenkins.io/browse/JENKINS-50219

          And the fix worked. "safeRestart" now works again.

          Thanks to tom_m_third_dimension for this:

          The fix is to enable the group policy setting "Local Computer Policy->Administrative Templates->System->User Profiles->Do not forcefully unload the users registry at user logoff".

          Niels Kristian Jensen added a comment - - edited SOLVED: On Jenkins Jenkins 2.249.3 running on Windows Server 2019, I had the same issue and fixed it by adding this access right to the jenkins install dir: "Everyone: read & execute" It turned out not to work always. We then saw the issue https://issues.jenkins.io/browse/JENKINS-50219 And the fix worked. "safeRestart" now works again. Thanks to tom_m_third_dimension for this: The fix is to enable the group policy setting "Local Computer Policy->Administrative Templates->System->User Profiles->Do not forcefully unload the users registry at user logoff".

          It is an issue with rights which can be fixed in the registry

          Niels Kristian Jensen added a comment - It is an issue with rights which can be fixed in the registry

            oleg_nenashev Oleg Nenashev
            hirre Hirad Asadi
            Votes:
            6 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: