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

Starting a Virtual Machine in Jenkins via batch script causes immediate crash and result in aborted state

      == Symptom ==
      Whenever I try and start a VM from the Execute Windows Batch Command
      inside a freestyle Jenkins job, my VM immediately crashes.

      == Details ==
      Trying to execute a batch script inside a Jenkins job that starts a
      Virtual Machine via a batch script will immediately crash and go to the
      aborted state.

      However, the same exact batch script can be ran by the host machine with
      the same variable and parameters perfectly fine manually.

      Also another workaround is to have the Virtual Box GUI interface open and
      running and the VM will seem to start.

      Is this a permissions issue?

      == Steps to be able to duplicate the bug ==
      1. Have an instance of Jenkins running on the host machine.
      2. Create a freestyle Job that will allow you to execute Windows batch
      scripts
      3. Then create a batch script as such

       cd "C:\Program Files\Oracle\VirtualBox"
       VBoxManage.exe "Name_OF_VM"
      

      4. save and build the job
      5. Observer that it starts up but then immediately crashes and goes to the
      abort state.

      == Versions Affected ==

      • Windows 8.1 64-bit (Host and Guest)
      • Version 4.3.22

      == Workaround ==
      Please see Details for any workarounds at the moment.

          [JENKINS-28731] Starting a Virtual Machine in Jenkins via batch script causes immediate crash and result in aborted state

          Daniel Beck added a comment -

          As of now it is not clear that this is in fact a bug in Jenkins, as there are significant differences between starting a batch command from a service (assuming Jenkins runs as one) and starting it in an interactive console.

          Depending on how you start the Windows node it may or may not have access to the UI. If it's a service, check the option "Service has access to desktop" (or similarly worded) and try again after a restart.

          Daniel Beck added a comment - As of now it is not clear that this is in fact a bug in Jenkins, as there are significant differences between starting a batch command from a service (assuming Jenkins runs as one) and starting it in an interactive console. Depending on how you start the Windows node it may or may not have access to the UI. If it's a service, check the option "Service has access to desktop" (or similarly worded) and try again after a restart.

          Matt Taylor added a comment -

          I make sure that the Jenkins service is not started automatically as a service. To do so, I open the “Services” tool (which is part of the “Administrative Tools” in the control panel), choose “Jenkins” service, stop the service, and set the “Startup type” to disabled:

          Then,

          Jenkins can be started manually using following command (from the installation folder):

          java -jar jenkins.war
          

          The reason being as Jenkins is normally started as a Windows service, it does not have sufficient rights to start UI-applications.

          Matt Taylor added a comment - I make sure that the Jenkins service is not started automatically as a service. To do so, I open the “Services” tool (which is part of the “Administrative Tools” in the control panel), choose “Jenkins” service, stop the service, and set the “Startup type” to disabled: Then, Jenkins can be started manually using following command (from the installation folder): java -jar jenkins.war The reason being as Jenkins is normally started as a Windows service, it does not have sufficient rights to start UI-applications.

          Daniel Beck added a comment -

          Do the steps you describe work, or do they still require the workaround to open Virtual Box beforehand?

          Daniel Beck added a comment - Do the steps you describe work, or do they still require the workaround to open Virtual Box beforehand?

          Matt Taylor added a comment -

          No sorry I was just stating the steps I am taking, Still does not work.

          Matt Taylor added a comment - No sorry I was just stating the steps I am taking, Still does not work.

            Unassigned Unassigned
            mtaylor Matt Taylor
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: