Delete your old GitLab CI pipelines

Unsplash: JJ Ying


Failed, passed, canceled, pending, there are a lot of chances that you have a long list of old jobs in your GitLab project.


First, we need to read the GitLab doc to know more about these endpoints and how to call them. You can read it here.

  • get a single pipeline
  • get variables of a pipeline
  • delete a pipeline

Call the GitLab API

As you may know; you need to be authenticated when calling the GitLab API. First, you need to create an Auth Token (here) with the API rights. Then, you will have to pass the token in the headers as “PRIVATE-TOKEN”.

curl --header "PRIVATE-TOKEN: <your_access_token>" ""
Axios configuration

List pipelines

Now that we are able to call GitLab API, we will list the project’s pipelines.

Axios — Get the list of pipelines

Delete a pipeline

To delete a pipeline, we will operate as follow:

Axios — Delete a pipeline

Delete all pipelines

As we know how to get pipelines and delete a single pipeline, we are able to loop on our pipeline array and delete them one by one as follow:

Axios — Delete pipelines

Wrap Up & Bonus

We are now able to clean the pipeline history in our GitLab projects. Here is the full code:

Final code



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store