/gitlab-project-doctor

CLI tool to cleanup a Gitlab project : Old pipelines, package registry, repositories

Primary LanguageRustMIT LicenseMIT

README FR README EN

MIT License Rust Forge MTE

Gitlab Project Doctor

A CLI tool to cleanup a Gitlab repository

Table of Contents
  1. About The Project
  2. Getting Started
  3. Roadmap
  4. Contributing
  5. License
  6. Contact
  7. Acknowledgments

About The Project

Gitlab Project doctor is a CLI tool to clean up Gitlab repositories, especially (for now) :

  • Old pipelines (with jobs and jobs artifacts)
  • Obsolete packages from package registry

It has first class support on Windows, macOS and Linux, with binary downloads available for every release .

Product Name Screen Shot

(back to top)

Getting Started

Installation

  1. Download the latest release for your OS
  2. Unzip and make gitlab-project-doctor executable
    chmod +x gitlab-project-doctor
  3. The environment variable GL_TOKEN needs to be set with a private token with sufficient privileges (owner of a project). For instance, on Linux :
    read -s GL_TOKEN # To secretly set the variable

Usage

  1. You can analyze a project from a local Git path whose first remote is a gitlab repository
    cd my_favorite_gitlab_repo
    gitlab-project-doctor .
  2. Or you can analyze a project from a remote Gitlab repository
    gitlab-project-doctor --url https://<your-gitlab-repo.com>/your-project-path

On Gitlab, if you allow duplicate packages (same name, same version), when you upload a package, the former one is not deleted. gitlab-project-doctor detects :

  • Generic duplicate packages: same name, same version
  • Maven SNAPSHOT duplicate packages: same artifactId, same SNAPSHOT version.

Usage on CI/CD

You can use gitlab-project-doctor in batch mode, for example in a CI/CD job.

In a Gitlab environment, here is an example of job declaration :

# A job in the .gitlab-ci.yml file of the project you want to clean
clean_project:
  image: $CI_REGISTRY/pub/numeco/gitlab-project-doctor:latest
  variables:
    # You need to declare a project-based private token with **owner** privilege
    GL_TOKEN: $GL_WRITE_TOKEN
  stage: build
  # The option -b activates the batch mode
  # The option -d specifies the number of days
  script:
    - gitlab-project-doctor --url $CI_PROJECT_URL -b -d 30

(back to top)

Roadmap

  • Initial release with generic and maven packages detection
  • Internationalization (French)
  • Batch-mode and container image (Alpine-based)
  • Container registry
  • Fat git repositories

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag " enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

Contact

Geoffrey Arthaud - numerique-ecologie@developpement-durable.gouv.fr

LinkedIn

(back to top)

Acknowledgments

(back to top)