Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins : delete workspace on slave too

Tags:

jenkins

I have a job with configuration matrix to perform build on 2 computer (master and slave). I have "Delete workspace before build starts" option checked on this job.

Unfortunately, workspace is delete only on "master" node, that is node where main job (job which launch all the job necessary to cover configuration matrix) is perform.

Workspace on second node is not delete.

I think it's a Jenkins error : because job has configuration matrix, there is a master job to launch other job. So "Delete workspace before build starts" option is apply only for this master job. I think this option should be apply for all matrix configuration job.

Someone know if I wrong ?

like image 825
romaric crailox Avatar asked Apr 07 '17 08:04

romaric crailox


People also ask

Can we delete the workspace in Jenkins?

Yes, you can delete the workspaces safely as well as jobs. The idea of the jobs directory is to allow you to display jobs history, if job history is not important for you then you can delete job directories from there.

Why is Jenkins suddenly unable to delete a workspace?

There is something locking the file or directory in the workspace. Someone has logged into Jenkins and is accessing the files from the workspace directly using the file system but not via Jenkins. The build process left a zombie program.

Does Jenkins delete workspace after build?

Freestyle jobs The plugin provides a build wrapper (Delete workspace before build starts) and a post build step (Delete workspace when build is done). These steps allow you to configure which files will be deleted and in what circumstances. The post build step can also take the build status into account.

How do I delete a workspace before Jenkins pipeline?

There is a way to clean up a workspace in Jenkins. You need to install the Workspace Cleanup Plugin. This plugin can clean up the workspace before build or after a build. Under Build Environment, check the box that says Delete workspace before build starts.


1 Answers

After the investigation I found out that Slaves workspaces are not deleted by "Delete workspace before build starts" method, workspace can be deleted on master only with the method (added by https://wiki.jenkins-ci.org/display/JENKINS/Workspace+Cleanup+Plugin).

The best option in this case is to use the script: https://gist.github.com/rb2k/8372402

Good resource to get additional info regarding Jenkins workspace deletion is: https://julienprog.wordpress.com/2016/04/14/clean-up-jenkins-workspaces/

like image 91
Olia Avatar answered Oct 10 '22 06:10

Olia