##// END OF EJS Templates
ci: add a small script one can run to purge older pipeline...
marmoute -
r53186:77b38c86 default
parent child Browse files
Show More
@@ -0,0 +1,36
1 #!/bin/bash
2 # A small script to cleanup old CI-pipeline that accumulate over time
3
4
5 d="`date -d '-1 month' --iso-8601`T00:00:00Z"
6
7 PROJECT_ID=22
8
9 token=$1
10
11 if [ -z $token ]; then
12 echo "USAGE: $0 GITLAB_TOKEN" >&2
13 exit 64
14 fi
15
16 get_ids() {
17 curl --silent "https://foss.heptapod.net/api/v4/projects/$PROJECT_ID/pipelines?updated_before=$d&per_page=100" | python3 -m json.tool | grep -E '"\bid": ([0-9]+),' | grep -oE '[0-9]+'
18 }
19
20 ids=`get_ids`
21 while [ -n "$ids" ]; do
22 echo '#########'
23 for pipeline_id in $ids; do
24 echo "deleting pipeline #$pipeline_id"
25 url="https://foss.heptapod.net/api/v4/projects/$PROJECT_ID/pipelines/$pipeline_id"
26 echo $url
27 curl \
28 --header "PRIVATE-TOKEN: $token"\
29 --request "DELETE"\
30 $url
31 done
32 ids=`get_ids`
33 if [ -n "$ids" ]; then
34 sleep 1
35 fi
36 done
General Comments 0
You need to be logged in to leave comments. Login now