Skip to content

Instantly share code, notes, and snippets.

@Pingu501
Pingu501 / gitlab-artifacts-cleanup.py
Created December 9, 2021 11:22
GitLab Artifacts Clean-Up
"""
This is a small python script to clear up old gitlab build artifacts.
There are 3 variables you should modify:
* base_url: path to your gitlab
* access_token: your personal access token to make gitlab api calls
* delete_everything_older_than: configure the timedelta as you wish
!!IMPORTANT!!
By default this script does only make dry-runs and does not actually delete any files!
#!/bin/bash
IPTABLES="/sbin/iptables"
IP6TABLES="/sbin/ip6tables"
# Helper function for confirming allow rules
confirm() {
while true; do
read -p "Allow $1? " yn
case $yn in