-
-
Notifications
You must be signed in to change notification settings - Fork 174
Expand file tree
/
Copy pathremove_old.sh
More file actions
executable file
·28 lines (23 loc) · 935 Bytes
/
remove_old.sh
File metadata and controls
executable file
·28 lines (23 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env bash
#
#./remove_old "ci-release.nodejs.org"
#
if [ ! -f /root/.jenkins_credentials ]; then
echo "Add credentials (user:token) to /root/.jenkins_credentials"
exit 1
fi
if [ "" == "$1" ]; then
echo "Pass URL to jenkins instance as first argument"
exit 1
fi
HOST=$1
DAYS=21
ROOTDIR=/var/lib/jenkins/jobs
REGEX="${ROOTDIR}/.*/builds/[0-9]+"
#JOBS="$ROOTDIR/*/builds/"
#MULTIJOBS="$ROOTDIR/*/configurations/axis-*/*/builds/"
CREDENTIALS=$(</root/.jenkins_credentials)
ssh -i /root/.ssh/nodejs_build_backup $HOST find "$ROOTDIR" -depth -type d -regex "$REGEX" -mtime +$DAYS -exec "rm -rvf '{}' \;"
# sxa: Skip due to jenkins bug - https://github.com/nodejs/build/issues/4247#issuecomment-4019757795
# JENKINS_CRUMB=$(curl -sL --user "$CREDENTIALS" https://$HOST/'crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)')
# curl -X POST -q --user "$CREDENTIALS" -H "$JENKINS_CRUMB" https://$HOST/reload