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

    Details

    • Similar Issues:

      Description

      == 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.

        Attachments

          Activity

          mtaylor Matt Taylor created issue -
          Hide
          danielbeck 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.

          Show
          danielbeck 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.
          Hide
          mtaylor 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.

          Show
          mtaylor 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.
          Hide
          danielbeck Daniel Beck added a comment -

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

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

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

          Show
          mtaylor Matt Taylor added a comment - No sorry I was just stating the steps I am taking, Still does not work.
          rtyler R. Tyler Croy made changes -
          Field Original Value New Value
          Workflow JNJira [ 163587 ] JNJira + In-Review [ 181295 ]

            People

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

              Dates

              • Created:
                Updated: