Skip to content

Instantly share code, notes, and snippets.

@njesper
njesper / keybase.md
Last active October 25, 2017 12:14
keybase.md

Keybase proof

I hereby claim:

  • I am njesper on github.
  • I am njesper (https://keybase.io/njesper) on keybase.
  • I have a public key whose fingerprint is 6F44 F042 9BB0 19FE 9291 93BA 83C7 4FDE 1347 0D1F

To claim this, I am signing this object:

@njesper
njesper / jenkins-groovy-system-script.groovy
Last active June 3, 2024 16:02 — forked from akomakom/jenkins-groovy-system-script.groovy
A jenkins script to clean up workspaces on slaves. On all slaves with less than X free GB, this script removes /slaves/workspace/* if slave is idle. If not idle, it removes /full/job/workspace/path for each job that isn't currently running. There are two versions: a "System Groovy Script" and a Jenkinsfile (Pipeline script)
/**
Jenkins System Groovy script to clean up workspaces on all slaves.
Check if a slave has < X GB of free space, perform cleanup if it's less.
If slave is idle, wipe out everything in the workspace directory as well any extra configured directories.
If slave is busy, wipe out individual job workspace directories for jobs that aren't running.
Either way, remove custom workspaces also if they aren't in use.
**/
import hudson.model.*;