Skip to content

Cleaning legacy Jenkins Storage

Cleaning jenkins storage

When recieving Zabbix alerts for low storage on the legacy Jenkins, we can prune old builds from some of the largest storage users on the cluster using this SOP.

Step 1: Creating a token
  • Firstly generate a jenkins token go to
  • Create a token from API token section
  • Set the username and token variables below
Step 2: Getting list of jobs
  • ssh into
  • Find the list of projects which are consuming most space by du -csh /var/lib/jenkins/* | grep 'G' | sort -r
Getting crumb api
  • Use curl to generate a Crumb token
CRUMB=$(curl 'https://$JENKINSUSER:$,":",//crumb)')
Deleting builds from job
  • Now with the crumb token set, we can delete the jobs using the API.
  • In the following example, update the jobname and start range/ end range values which correspond with the build numbers in the jobname:
curl -H "$CRUMB" -X POST "https://$JENKINSUSER:$<jobname>/[<start>-<end>]/doDelete"