3

I am encountering a strange issue, when i run vagrant up, the virtual machine builds up fine and works as intended, but when I run the same command in a Jenkinsfile pipeline, after the build is completed, the virtual machine shutsdown with a created log.

Log created: 2021-01-15T12:32:44.144568000Z
Process ID:  9678 (0x25ce)
Parent PID:  1 (0x1)
Executable:  /usr/lib/virtualbox/VBoxSVC
Arg[0]: /usr/lib/virtualbox/VBoxSVC
Arg[1]: --auto-shutdown
AddRef: illegal refcnt=3221225469 state=2

This is the pipeline code for vagrant

stage('Run Vagrant'){
    sh 'cd /var/lib/jenkins/workspace/jenkins-file_master/ansible/; vagrant up'
}

Jenkins config is set for the same user, so that the environment is the same.

# user and group to be invoked as (default to jenkins)
JENKINS_USER=myusername
JENKINS_GROUP="adm cdrom sudo dip plugdev lpadmin lxd sambashare docker vboxusers"
1
  • This question is the same question as in superuser.com/questions/1406120/…, but the system won't let me flag as duplicate because that question has received very little attention.
    – jayhendren
    Commented Jan 19, 2021 at 17:26

1 Answer 1

1

You're running into the Process Tree Killer, a "feature" of Jenkins which kills all processes started by a build when that build terminates. The intention is to prevent Jenkins builds from starting services, daemons, or other long-lived processes which may affect other builds or the Jenkins machine itself.

There are a couple ways to disable this feature, as stated in the wiki and this SO question:

Those fixes are:

  • Set the Java parameter -Dhudson.util.ProcessTree.disable=true on your Jenkins process (personally, I've had the best luck with this solution)
  • During your build, change the value of the environment variable BUILD_ID (for Freestyle and other non-Pipeline jobs) or JENKINS_NODE_COOKIE (for Pipeline jobs)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .