A Python CLI tool to delete all CI/CD pipelines for a specific branch of a GitLab project. Useful for cleaning up pipeline history after merging or deleting feature branches.
- Branch-targeted deletion — Delete all pipelines for a specific branch
- Before/after comparison — Displays pipeline list before and after deletion
- Interactive confirmation — Requires typing
YESbefore any deletion - Pagination support — Handles projects with hundreds of pipelines
- Self-hosted support — Works with gitlab.com and self-hosted instances
gitlab-pipeline-cleaner/
├── app/
│ ├── gitlab_client.py # Shared GitLab API client
│ └── clean_branch_pipelines.py # Delete pipelines for a branch
├── config/
│ └── settings.py
├── .env.example # Environment variables template
├── requirements.txt
├── LICENSE
└── README.md
- Python 3.8+
- A GitLab instance (gitlab.com or self-hosted)
- A GitLab Personal Access Token with
apiscope
git clone https://github.com/cegape/gitlab-pipeline-cleaner.git
cd gitlab-pipeline-cleaner
pip install -r requirements.txtcp .env.example .envEdit .env:
GITLAB_BASE_URL=https://gitlab.com
GITLAB_TOKEN=your-personal-access-tokenDelete all pipelines for a branch:
python app/clean_branch_pipelines.py --project-id 12345 --branch feature/my-branchThe tool will:
- List all pipelines for the branch
- Ask you to type
YESto confirm - Delete all pipelines one by one
- Show remaining pipelines after deletion
Your project ID is visible on the GitLab project page (under the project name) or via:
# Using GitLab API
curl --header "PRIVATE-TOKEN: your-token" "https://gitlab.com/api/v4/projects?search=my-project"| Guard | Description |
|---|---|
| Interactive confirmation | Requires typing YES before any deletion |
| Before/after display | Shows pipeline list before and after to verify results |
| Branch-scoped | Only affects pipelines for the specified branch |
This project is licensed under the MIT License.