Jenkins Job Killer is a Python script designed to manage and terminate Jenkins jobs that are running longer than a specified timeout. This tool can help maintain the health of your Jenkins instance by preventing runaway jobs.
- Authenticate with Jenkins server
- Display Jenkins server version
- List current queued jobs
- Identify and terminate running jobs that exceed a specified timeout
- Dry run mode for safe testing
You can install Jenkins Job Killer by downloading the binary from the releases page and placing it in your /usr/local/bin
directory.
Run the following command to download and install Jenkins Job Killer:
curl -L -o jjkiller https://github.com/matandomuertos/jenkins-job-killer/releases/latest/download/jjkiller_darwin_amd64 && chmod +x jjkiller && sudo mv jjkiller /usr/local/bin/jjkiller
curl -L -o jjkiller https://github.com/matandomuertos/jenkins-job-killer/releases/latest/download/jjkiller_darwin_arm64 && chmod +x jjkiller && sudo mv jjkiller /usr/local/bin/jjkiller
curl -L -o jjkiller https://github.com/matandomuertos/jenkins-job-killer/releases/latest/download/jjkiller_linux_amd64 && chmod +x jjkiller && sudo mv jjkiller /usr/local/bin/jjkiller
Jenkins Job Killer provides various command-line options to interact with your Jenkins server. Below are some examples of how to use it.
jjkiller --url http://your-jenkins-url -u your-username -p your-password
-url
,--url
: Specify Jenkins server URL (required)-u
,--user
: Specify Jenkins user (required)-p
,--password
: Specify Jenkins password or token (required)--queue
: Clean up queued builds--jenkins-version
: Print Jenkins server version--version
: Print jjkiller version and exit--time-out
,-t
: Set timeout for stopping builds in hours (default: 4)--dry-run
: Run in dry mode (no actions will be taken)
jjkiller --url http://your-jenkins-url -u your-username -p your-password --version
jjkiller --url http://your-jenkins-url -u your-username -p your-password --queue
jjkiller --url http://your-jenkins-url -u your-username -p your-password --time-out 6
jjkiller --url http://your-jenkins-url -u your-username -p your-password --dry-run
- Python 3.6+
jenkins
Python packageargparse
Python packagetabulate
Python package
-
Clone the repository
git clone https://github.com/matandomuertos/jenkins-job-killer.git cd jenkins-job-killer
-
Install the required packages
pip install -r requirements.txt
-
Run the script
python src/jobKiller.py --url http://your-jenkins-url -u your-username -p your-password
Contributions are welcome! Please open an issue or submit a pull request with your changes.
This project is licensed under the MIT License. See the LICENSE file for details.