Job_detection is a Go-based tool designed to manage and clean up GitLab CI and GitHub Workflows after job is finished. It monitors Docker events to detect when relevant containers start or stop and performs thorough cleanup operations to ensure no residual resources remain.
- Monitors Docker events for container lifecycle changes.
- Identifies and matches containers based on configurable job patterns.
- Stops and removes containers, networks, and volumes associated with completed GitLab CI jobs.
- Supports Docker Compose setups by running
docker-compose downfor multi-container applications. - Handles graceful shutdowns to ensure cleanup is performed even when the script terminates unexpectedly.
- Go 1.21 or later
- Docker installed and running
- GitLab Runner installed and configured
-
Clone the Repository:
git clone [email protected]:Dokuqui/Job_Detection.git cd Job_Detection
-
Configure Job Patterns: Create or modify the
jobPattern.jsonfile to specify patterns for identifying relevant containers.{ "jobPatterns": [ "^/runner-.*-project-.*-concurrent-.*-.*-build$", "^/runner-.*-project-.*-concurrent-.*-.*-test$", "^/runner-.*-project-.*-concurrent-.*-.*-deploy$" ] } -
Run the Script:
go run github-detection.go `or` go run gitlab-detection.go
For detailed documentation for gitlab, please visit our Readme page.
Also in each package exists dedicated test for several functions. To run them you can run in your terminal command.
Run all test:
go test -v ./...