Search code examples
gitlabgitlab-cigitlab-ci-runner

How to delete gitlab CI jobs pipelines logs/builds and history


How can we configure gitlab to keep only the last 10 CI jobs/builds and keep deleting the rest?

For example , in Jenkins , we can configure the job to keep only last X builds.


Solution

  • I think Gitlab doesn't support this feature. But you can create this functionality on your own using Gitlab API and webhooks.

    When you push to repo (and pipeline started) it will trigger webhook which can read your CI history via API => you can delete whatever you want.

    Here is docs for pipeline events

    Here is docs for job API

    FYI I use similar solution. I have deployed server for each branch (every brach has MR). When is MR closed it delete deployed server. It is very reliable.