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

Ijaz Ahmad Khan picture Ijaz Ahmad Khan · Nov 17, 2018 · Viewed 25.3k times · Source

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.

Answer

Routhinator picture Routhinator · Apr 23, 2019

UPDATE

As of Gitlab Release 12.6, deleting a pipeline is now an option in the GUI for owners:

  • Click the pipeline you want to remove in the pipelines list
  • Hit the red Delete button in the upper right of the pipeline details page.

As of Gitlab Release 11.6, deleting a pipeline is now an option, for maintainers only, via the API.

You need:

  • An API token
  • The id of the project
  • The pipeline_id of the pipeline you wish to remove.

Example using curl from the docs for project id: 1 and pipeline_id: 4:

curl --header "PRIVATE-TOKEN: <your_access_token>" --request "DELETE" "https://gitlab.example.com/api/v4/projects/1/pipelines/46"

Documentation is here