Skip to content

Instantly share code, notes, and snippets.

@msutter
msutter / gist:e580a1b48a8551128217225fe4a8568b
Created January 8, 2018 14:59 — 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.
/**
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.*;
@msutter
msutter / cleanupUnusedWorkspaceInSlaves.groovy
Created January 8, 2018 15:41 — 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) {

File Manipulation Approaches

Full configurations

Static content

  • Software/script => have you considered packaging it?
  • binary/large data file => add metadata (git + vcsrepo type, maybe even git-annex or git-lfs?)
  • Puppet >= 3.7:
@msutter
msutter / GNUPG_agent_forwarding.md
Last active February 27, 2020 10:26 — forked from TimJDFletcher/GNUPG_agent_forwarding.md
GnuPG agent forwarding

Forward GnuPG agent from macOS to Linux

On the remote machine

Run gpg once as your to create the directory structure

gpg --list-keys

For remote systemd based hosts