A CLI tool for Jenkins
Project description
Jenkins Terminal Tool
A command-line tool for interacting with Jenkins, allowing you to configure Jenkins credentials, trigger builds, and get job statuses.
Features
- Set Jenkins configuration parameters interactively or via command-line options
- Trigger Jenkins jobs with parameters
- Get the status of Jenkins jobs
- Fetch and display Jenkins job console outputs
- List the builds of a specified Jenkins job
- Template job feature to automatically save and read last executed job
Installation
Using pip
-
Install the tool:
pip install jenkins-terminal
-
Run the CLI tool:
jenkins <command>
Usage
Configuration
You can set Jenkins configuration parameters either interactively or via command-line options.
Interactively
Run the following command and follow the prompts to enter your Jenkins URL, username, and API token:
jenkins config
Command-line options
You can also set the configuration parameters using command-line options:
jenkins config --username <username> --url <url> --token <token>
Trigger a Jenkins Job
Trigger a Jenkins job with parameters:
jenkins build <job> --param/-p <key1>=<value1> --param/-p <key2>=<value2>
Trigger a Jenkins job with parameters from a YAML file:
jenkins build <job> --file/-f <file>
Trigger a Jenkins job with parameters from specific build:
jenkins build <job> --load/-l <build-number>
Also, you can combine the above options:
jenkins build <job> -l <build-number> -f <file> -p <key1>=<value1> -p <key2>=<value2>
The YAML file should contain the job parameters in the following format:
key1: value1
key2: value2
Get Jenkins Job Status
Get the status of a Jenkins job:
jenkins status <job> --build-number/-b <number>
Fetch Jenkins Job Console Output
Fetch and display the console output of the latest or a specific Jenkins job build:
jenkins output <job> --build-number/-b <number> --max-lines/-l <number>
List the builds of Jenkins Job
List the builds of a specified Jenkins job:
jenkins builds <job>
Template Job
Save the last executed job as a template in the ~/.config/jenkins.yaml
:
template:
builds:
job1:
build_number: 10
parameters:
SITE: tpe001
job2:
build_number: 20
parameters:
SITE: tpe001
job3:
build_number: 30
parameters:
ENV: test1
SITE: tpe002
job: job3
You can run commands without specifying the job name and parameters:
jenkins build
Output:
╭─ Parameters for job: job3 ──────────────────────────────────────────────╮
│ ENV = test1 │
│ SITE = tpe002 │
╰─────────────────────────────────────────────────────────────────────────╯
Do you want to proceed with these parameters? [y/n]:
Acknowledgements
- Typer - CLI library for Python
- Rich - Rich text and beautiful formatting in the terminal
- Jenkins - The leading open source automation server
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for jenkins_terminal-0.5.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 720a4eff25db4eb5f14425659e5cb3f5c6da130559750fb68f31d07a302f700e |
|
MD5 | c33a8345bc473bb8676fe4eb56632b4c |
|
BLAKE2b-256 | d1ccf57058d1995332aa86f71ae0c57203b1a7cae80d36df667ccac28a0cf674 |