Running a command before wiping the workspace

42 views
Skip to first unread message

Björn Stabel

unread,
Oct 23, 2015, 12:12:22 PM10/23/15
to jenkins...@googlegroups.com
Hello,

I have a job that constructs a Vagrant environment in the workspace
directory.
To that Vagrant environment belongs a VirtualBox VM, stored elsewhere.
Vagrant keeps track of which Vagrant environment belongs to which
VirtualBox VM through a directory named ".vagrant" in the workspace
directory.

The problem is this:
If a user wipes the workspace of that job, the .vagrant directory is
gone, but the VirtualBox VM still exists.
The next time the job is run, Vagrant cannot find the existing VM, so a
new VM is created, taking up extra disk space.

Preparing the VM takes some time and involves creating a snapshot on
which all future runs can base, so destroying the VM in a post-build
step would significantly increase build times.

Is there a way I could tell Jenkins to destroy the VM (by running
"vagrant destroy -f", for example) before wiping the workspace?

Björn Stabel

unread,
Nov 24, 2015, 6:28:19 AM11/24/15
to jenkins...@googlegroups.com
I'm still having this problem. Is anyone aware of a solution, like a
pre-wipe action plugin?

Mark Waite

unread,
Nov 24, 2015, 6:44:05 AM11/24/15
to jenkins...@googlegroups.com
After you reviewed https://wiki.jenkins-ci.org/display/JENKINS/pre-scm-buildstep for the Pre-SCM Build Step?

You may also want to consider the advice in http://stackoverflow.com/questions/10123914/how-to-add-some-prebuild-steps-to-jenkins and see if there is a way to add that step to the build script itself, rather than making it part of the Jenkins job definition.

Mark Waite

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/565449C7.1000400%40data-experts.de.
For more options, visit https://groups.google.com/d/optout.

Björn Stabel

unread,
Nov 26, 2015, 3:49:56 AM11/26/15
to jenkins...@googlegroups.com
I don't want to run a build step pre-scm, but pre-wipe, i.e. when the user clicks "wipe workspace", but before the workspace is actually wiped.

Baptiste Mathus

unread,
Nov 27, 2015, 3:18:02 AM11/27/15
to jenkins...@googlegroups.com

Hi,
I've never seen a way to do that, neither a plugin.
BTW, that would require having an extension point on a WS wipeout request, not sure there is one.

Cheers

Reply all
Reply to author
Forward
0 new messages