view contrib/cleanup-pipeline.sh @ 52304:04b9a56c2d25

rust-lib: only export very common types to the top of the crate This was done very early in the Rust project's lifecycle and I had very little Rust experience. Let's keep the `DirstateParents` since they'll pop up in all higher-level code and make the rest more explicit imports to make the imports less confusing and the lib less cluttered.
author Raphaël Gomès <rgomes@octobus.net>
date Mon, 04 Nov 2024 11:13:05 +0100
parents 77b38c86915d
children
line wrap: on
line source

#!/bin/bash
# A small script to cleanup old CI-pipeline that accumulate over time


d="`date -d '-1 month' --iso-8601`T00:00:00Z"

PROJECT_ID=22

token=$1

if [ -z $token ]; then
    echo "USAGE: $0 GITLAB_TOKEN" >&2
    exit 64
fi

get_ids() {
    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]+'
}

ids=`get_ids`
while [ -n "$ids" ]; do
    echo '#########'
    for pipeline_id  in $ids; do
        echo "deleting pipeline #$pipeline_id"
        url="https://foss.heptapod.net/api/v4/projects/$PROJECT_ID/pipelines/$pipeline_id"
        echo $url
        curl \
            --header "PRIVATE-TOKEN: $token"\
            --request "DELETE"\
            $url
    done
    ids=`get_ids`
    if [ -n "$ids" ]; then
        sleep 1
    fi
done