Skip to content

Instantly share code, notes, and snippets.

View germanattanasio's full-sized avatar
🇦🇷
Learning

German Attanasio germanattanasio

🇦🇷
Learning
View GitHub Profile
@germanattanasio
germanattanasio / cleanupUnusedWorkspaceInSlaves.groovy
Created March 8, 2017 19:48 — forked from ceilfors/cleanupUnusedWorkspaceInSlaves.groovy
When you delete jobs in Jenkins, the corresponding workspaces in the build slaves won't be deleted automatically. This Jenkins script will go to each slave and check if the jobs are already deleted in Jenkins master and delete the workspace.
import com.cloudbees.hudson.plugins.folder.Folder
import hudson.FilePath
import jenkins.model.Jenkins
def boolean isFolder(String name) {
def item = Jenkins.instance.getItemByFullName(name)
return item instanceof Folder
}
def deleteUnusedWorkspace(FilePath root, String path) {