Blame docs/operations/ci/cleaning_legacy_jenkins_storage.md

47c289
# Cleaning jenkins storage
47c289
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.
47c289
47c289
47c289
## Step 1: Creating a token
47c289
* Firstly generate a jenkins token go to `https://ci.centos.org/user/username/configure`
47c289
* Create a token from API token section
47c289
* Set the username and token variables below
47c289
47c289
```
47c289
JENKINSUSER=username
47c289
JENKINSAPITOKEN=token
47c289
```
47c289
47c289
47c289
## Step 2: Getting list of jobs
47c289
* ssh into `jenkins.ci.centos.org`
47c289
* Find the list of projects which are consuming most space by `du -csh /var/lib/jenkins/* | grep 'G' | sort -r`
47c289
47c289
47c289
## Getting crumb api
47c289
* Use curl to generate a Crumb token 
47c289
47c289
```
47c289
CRUMB=$(curl 'https://$JENKINSUSER:$JENKINSAPITOKEN@ci.centos.org/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)')
47c289
```
47c289
47c289
47c289
## Deleting builds from job
47c289
* Now with the crumb token set, we can delete the jobs using the API.
47c289
* In the following example, update the `jobname` and `start range/ end range` values which correspond with the build numbers in the jobname:
47c289
47c289
```
47c289
curl -H "$CRUMB" -X POST "https://$JENKINSUSER:$JENKINSAPITOKEN@ci.centos.org/job/<jobname>/[<start>-<end>]/doDelete"
47c289
```