0

I have a jenkins multi branch project, that builds on every commit and pushes the image to our private registry:

docker-reg:5000/<project>/<branch>:latest
docker-reg:5000/<project>/<branch>:<build-server>-<build-number>

How can I delete the labels in the docker registry in order to let the garbage collector kick in upon:

  • build gets orphaned after some time
    • remove <project>/<branch>:<build-server>-<build-number
  • branch gets merged and jenkins sub project gets automatically deleted
    • remove <project>/<branch>:latest
0

This is a very complicated issue for a few reasons:

  1. The biggest problem is Jenkins does not have any way of notifying you when a branch is deleted or a OR is merged. There are a lot of issues in Jenkin's jira, but from what I know - this one is the monitored one.

  2. You would somehow need to keep a record of all of the published tags.

Overall I don't see how you'd achieve this as it's simply not possible from Jenkin's side. It would be cool if somebody else has found a solution to this. I have looked for one a few times already without any luck.

  • I see, would this be possible in gitlab? – DaSteph Aug 8 at 20:14
  • Unfortunately I don't use GitLab very much. Maybe you could hook into the Stop an environment. – tftd Aug 9 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.