Skip to content

Instantly share code, notes, and snippets.

@sytsereitsma
Last active August 26, 2015 15:37
Show Gist options
  • Save sytsereitsma/7e356fc59f3b2bb458c5 to your computer and use it in GitHub Desktop.
Save sytsereitsma/7e356fc59f3b2bb458c5 to your computer and use it in GitHub Desktop.
void cleanNode(Node node, item_to_wipe) {
workspacePath = node.getWorkspaceFor(item_to_wipe)
if(!workspacePath){
println(" Failed to find workspace path on ${node.name}.")
return
}
if (workspacePath.exists())
{
try {
workspacePath.deleteRecursive()
println(" Deleted from ${node.name}")
}
catch(IOException e){
pathAsString = workspacePath.getRemote()
println(" Failed to delete from ${node.name} (location ${pathAsString}")
}
}
}
def projects=Jenkins.instance.getView(" HEAD")
for (project in projects.items) {
println("${project.name}:")
for (node in Jenkins.instance.getNodes()) {
cleanNode(node, project)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment