mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-27 17:10:22 -04:00
Add convenience script for pruning old dev branch CI jobs
This commit is contained in:
parent
061e6432bf
commit
114955f121
1 changed files with 26 additions and 0 deletions
26
dev-tools/delete_branch_jobs.sh
Executable file
26
dev-tools/delete_branch_jobs.sh
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
if [ "$#" -ne 1 ]; then
|
||||
printf 'Usage: %s <branch> \n' "$(basename "$0")"
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
BRANCH="$1"
|
||||
|
||||
if [ -z "${JENKINS_USERNAME}" ] || [ -z "${JENKINS_TOKEN}" ]; then
|
||||
echo "You must set JENKINS_USERNAME and JENKINS_TOKEN environment variables."
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
echo "Deleting Jenkins jobs..."
|
||||
curl -s https://elasticsearch-ci.elastic.co/api/json \
|
||||
| jq -r ".jobs | .[] | select(.name | startswith(\"elastic+elasticsearch+${BRANCH}\")) | .url" \
|
||||
| xargs -L 1 curl -u $JENKINS_USERNAME:$JENKINS_TOKEN -X DELETE
|
||||
|
||||
echo "Deleting views..."
|
||||
curl -s https://elasticsearch-ci.elastic.co/api/json \
|
||||
| jq -r ".views | .[] | select(.name == \"Elasticsearch ${BRANCH}\") | .url" \
|
||||
| xargs -L 1 -I '{}' curl -u $JENKINS_USERNAME:$JENKINS_TOKEN -X POST "{}/doDelete"
|
||||
|
||||
echo "Done."
|
Loading…
Add table
Add a link
Reference in a new issue