Sign inSign up

cakuki/gitlab-artifact-cleanup

By cakuki

•Updated over 8 years ago

This tool erases all untagged build data with artifacts using the GitLab API.

Image
0

4.7K

cakuki/gitlab-artifact-cleanup repository overview

⁠gitlab-artifact-cleanup⁠

Currently (as of GitLab 8.12) there are no admin tools for cleaning up build artifacts (see issue #18351⁠). This script erases build artifacts using the GitLab API.

Note: This tool actually erases the entire build which includes the build output log as well as the artifacts. See #3 for more information.

⁠Requirements

  • python-gitlab⁠ - Python GitLab API client (At least version 1.3.0)
  • python-dateutil⁠ - A robust ISO-8601 timestamp parser, among other things
  • pytz⁠ - Timezone info (Only required if you are using Python 2)

Run pip install -r requirements.txt to install requirements locally.

⁠Usage

This script leverages the python-gitlab config file⁠. Just like the gitlab CLI tool, you can specify a non-default Gitlab server with the -g/--gitlab option. Mind that you have to set api_version = 4 for this tool to work.

Example ~/.python-gitlab.cfg configuration:

[global]
ssl_verify = true
url = https://gitlab.some.whe.re
private_token = vTbFeqJYCY3sibBP7BZM
api_version = 4

You can specify any number of projects with the -p/--project option:

$ gitlab-artifact-cleanup --project jreinhart/artifact-test --project jreinhart/python-gitlab

Or, you can cleanup all projects visible to you:

$ gitlab-artifact-cleanup --all-projects

Builds for tags are never removed.

⁠Usage via docker

You can run the tool via docker:

$ docker run --rm \
    -e URL=https://gitlab.myco.com \
    -e PRIVATE_TOKEN=vTbFeqJYCY3sibBP7BZM \
    cakuki/gitlab-artifact-cleanup \
        --project jreinhart/artifact-test \
        --project jreinhart/python-gitlab

⁠License

This software is released under the MIT License⁠.

Tag summary

Content type

Image

Digest

Size

35.1 MB

Last updated

over 8 years ago

docker pull cakuki/gitlab-artifact-cleanup