Commit 748b51ad authored by Peter Hutterer's avatar Peter Hutterer
Browse files

doc: document how to delete images


Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent c6a21cbd
.. _ci-fairy:
ci-fairy - a CLI tool
=====================
......
......@@ -311,3 +311,46 @@ actual success status of the CI job.
Deleting container images
-------------------------
Unfortunately, deleting container images is nontrivial with templates and it
requires extra authentication tokens. Use the
:ref:`ci-fairy tool <ci-fairy>` for this task:
.. code-block:: yaml
delete-containers:
extends:
- .fdo.distribution-image@fedora
- .myproject.fedora:30
stage: cleanup
image: golang:alpine
before_script:
- apk add python3 git
- pip3 install git+http://gitlab.freedesktop.org/freedesktop/ci-templates
script:
# Go to your Profile, Settings, Access Tokens
# Create a personal token with 'api' scope, copy the value.
# Go to CI/CD, Schedules, schedule a new monthly job (or edit the existing one)
# Define a variable of type File named AUTHFILE. Content is that token
# value.
#
# This example assumes that you want to delete all but the current tag
- ci-fairy -v --authfile $AUTHFILE delete-image
--repository $FDO_DISTRIBUTION_NAME/$FDO_DISTRIBUTION_VERSION
--exclude-tag $FDO_DISTRIBUTION_TAG
only:
- schedules
This is a job to run container cleanup on a `schedule job
<https://docs.gitlab.com/ee/ci/pipelines/schedules.html>`__. We get
``$FDO_DISTRIBUTION_NAME`` by extending ``.fdo.distribution-image@fedora``
but since we only need to run a simple python tool, we can just run off a
``golang:alpine`` image.
All other variables are courtesy of ``.myproject.fedora:30`` (see
:ref:`templates_extends`)
Because of restrictions in GitLab, this can only be run with an API token,
``CI_JOB_TOKEN`` does not have permissions to delete images.
The ``ci-fairy`` command as run here will delete all images in the
``fedora/30`` image repository, excluding the one with the tag ``2020-03-10.0``.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment