Python Jenkins CLI tool
Project description
jcli
A command-line tool for managing Jenkins servers. jcli wraps the Jenkins REST API into readable commands that work the way you'd expect, with table, JSON, and YAML output options.
Features
- 8 command modules covering jobs, builds, nodes, plugins, credentials, pipelines, views, and system management
- Multiple output formats: human-readable tables (default, via Rich), JSON, and YAML
- Multi-profile support via
~/.jcli/config.yamlwith environment variable overrides - Automatic CSRF (Crumb) handling for Jenkins servers with CSRF protection enabled
- Built with Click and Rich for a polished terminal experience
Requirements
- Python 3.10 or later
- A Jenkins server running Jenkins 2.x or later
Installation
Install from source with pip:
pip install .
Or in editable mode for development:
pip install -e ".[dev]"
After installation, jcli is available as a console script.
Quick Start
1. Configure your Jenkins connection
Create a configuration file at ~/.jcli/config.yaml:
active_profile: default
profiles:
default:
url: https://jenkins.example.com
username: admin
api_token: "11abcdef0123456789abcdef0123456789ab"
description: "Production Jenkins"
If the file doesn't exist, jcli creates it with a template on first run.
To generate an API token, go to your Jenkins user page: Your Username > Configure > API Token > Add new Token.
2. Run your first command
jcli job list
If your server is configured correctly, this prints a table of all Jenkins jobs.
Configuration
Config file
jcli stores profiles in ~/.jcli/config.yaml. Each profile has four fields:
| Field | Description |
|---|---|
url |
Jenkins server URL |
username |
Jenkins username |
api_token |
Jenkins API token |
description |
Human-readable description |
The active_profile key selects which profile to use.
To add another server profile, edit the file and add a new entry under profiles:
active_profile: prod
profiles:
prod:
url: https://jenkins.prod.example.com
username: admin
api_token: "..."
description: "Production"
staging:
url: https://jenkins.staging.example.com
username: admin
api_token: "..."
description: "Staging"
Environment variables
Environment variables override config file values. This is useful in CI pipelines.
| Variable | Overrides |
|---|---|
JCLI_URL |
url |
JCLI_USERNAME |
username |
JCLI_API_TOKEN |
api_token |
JCLI_PROFILE |
active_profile |
Set JCLI_PROFILE to select a profile without editing the config file.
CLI options
Profile and server can also be set with command-line flags:
jcli -p staging job list # use the "staging" profile
jcli -s https://ci.example.com job list # override server URL
jcli -d job list # enable debug logging
Run jcli --help for the full option list.
Command Reference
Global options
Every command accepts these global flags before the subcommand:
-d, --debug Enable debug output
-f, --format [table|json|yaml] Output format (default: table)
-p, --profile TEXT Configuration profile name
-s, --server TEXT Jenkins server URL
job — Manage Jenkins jobs
jcli job list List all jobs
jcli job get JOB_NAME Show details for a specific job
jcli job create JOB_NAME -f job-config.xml Create a new job from XML config file
jcli job config JOB_NAME Print the XML configuration of a job
jcli job copy SOURCE_JOB NEW_NAME Copy a job to a new name
jcli job enable JOB_NAME Enable a disabled job
jcli job disable JOB_NAME Disable a job
jcli job delete JOB_NAME Delete a job
build — Manage Jenkins builds
jcli build list JOB_NAME List recent builds for a job
jcli build get JOB_NAME BUILD_NUMBER Show details for a specific build
jcli build trigger JOB_NAME Trigger a new build
jcli build log JOB_NAME BUILD_NUMBER Show console log for a build
jcli build stop JOB_NAME BUILD_NUMBER Stop a running build
jcli build queue Show the current build queue
node — Manage Jenkins nodes (agents)
jcli node list List all nodes
jcli node get NODE_NAME Get details of a specific node
jcli node delete NODE_NAME Delete a node
jcli node toggle NODE_NAME --offline Take a node offline
jcli node toggle NODE_NAME --online Bring a node back online
plugin — Manage Jenkins plugins
jcli plugin list List installed plugins
jcli plugin get PLUGIN_NAME Show details for a single plugin
jcli plugin install PLUGIN_NAME Install a plugin
jcli plugin uninstall PLUGIN_NAME Uninstall a plugin
credential — Manage Jenkins credentials
jcli credential list List credentials
jcli credential get CREDENTIAL_NAME Get credential details
jcli credential create -f cred-config.xml Create a credential from XML config
jcli credential delete CREDENTIAL_NAME Delete a credential
pipeline — Manage Jenkins pipelines
jcli pipeline stages JOB_NAME BUILD_NUMBER List stages for a Pipeline build
jcli pipeline log JOB_NAME BUILD_NUMBER Get log output for a Pipeline step
jcli pipeline pending JOB_NAME BUILD_NUMBER Show pending input actions
jcli pipeline validate -f Jenkinsfile Validate a Jenkinsfile against the server
view — Manage Jenkins views
jcli view list List all views
jcli view get VIEW_NAME Get details for a view
jcli view create -f view-config.xml Create a view from XML config
jcli view delete VIEW_NAME Delete a view
system — Jenkins system information and management
jcli system info Show system version and stats
jcli system load Show queue length and executor counts
jcli system quiet-down Put Jenkins into quiet-down mode
jcli system cancel-quiet-down Cancel quiet-down mode
jcli system restart Trigger a safe restart
jcli system script "println('hello')" Execute a Groovy script on the server
Output Formats
jcli supports three output formats, selectable with -f / --format:
jcli -f table job list # Rich-formatted table (default)
jcli -f json job list # JSON output
jcli -f yaml job list # YAML output
Table mode uses the Rich library with alternating row colors and auto-width columns. Pipe the output to any file or command as needed.
Development
Setup
git clone <repo-url> jcli
cd jcli
pip install -e ".[dev]"
Running tests
The test suite uses pytest with the responses library for HTTP mocking:
pytest
For coverage:
pytest --cov=jcli --cov-report=term-missing
Project structure
jcli/
cli.py Main CLI entry point (Click group)
__init__.py Version
plugins/ Command modules (one per Jenkins domain)
job.py
build.py
node.py
plugin.py
credential.py
pipeline.py
view.py
system.py
sdk/ Shared libraries
client.py Jenkins REST API client (HTTP, auth, crumb)
config.py Configuration management (YAML, env vars)
output/
formatter.py Table/JSON/YAML output formatting
exceptions.py Typed exceptions
tests/ pytest test suite
Dependencies
| Package | Purpose |
|---|---|
| click >= 8.1.0 | CLI framework |
| requests ~= 2.31 | HTTP client |
| pyyaml ~= 6.0.1 | YAML config parsing |
| rich >= 13.7.1 | Terminal formatting (tables) |
| argcomplete >= 3.3 | Shell tab completion |
Dev dependencies (optional [dev] extra):
| Package | Purpose |
|---|---|
| pytest >= 7.0 | Test runner |
| pytest-cov >= 4.0 | Coverage reporting |
| responses >= 0.23 | HTTP response mocking |
License
MIT
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 Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_jcli-0.1.0.tar.gz.
File metadata
- Download URL: python_jcli-0.1.0.tar.gz
- Upload date:
- Size: 73.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d41691687cf64c89b706dd4a9460e32820d26aa8fae21280ec96d0361db7db4
|
|
| MD5 |
a62523edb50651751b481e50575a7dd4
|
|
| BLAKE2b-256 |
fe15803cbba7bc51f71813d5d0505ea05fee9b38f08c99422eedc0a347075ad0
|
Provenance
The following attestation bundles were made for python_jcli-0.1.0.tar.gz:
Publisher:
publish.yml on guolong123/jcli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_jcli-0.1.0.tar.gz -
Subject digest:
4d41691687cf64c89b706dd4a9460e32820d26aa8fae21280ec96d0361db7db4 - Sigstore transparency entry: 1797966896
- Sigstore integration time:
-
Permalink:
guolong123/jcli@12cbf354bd7d249d63e1c46fd6f12a6c5f6d199f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/guolong123
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@12cbf354bd7d249d63e1c46fd6f12a6c5f6d199f -
Trigger Event:
release
-
Statement type:
File details
Details for the file python_jcli-0.1.0-py3-none-any.whl.
File metadata
- Download URL: python_jcli-0.1.0-py3-none-any.whl
- Upload date:
- Size: 53.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f44fac07f525dff897cc4862a16cde51a3bc8f114265796b1f2716ef96c648c7
|
|
| MD5 |
81248b7898883a4029ae2d0adc39a483
|
|
| BLAKE2b-256 |
c10887a2991b423db655e4d42ad24b9a8397c84aecf1a25940c231b6fa768ff7
|
Provenance
The following attestation bundles were made for python_jcli-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on guolong123/jcli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_jcli-0.1.0-py3-none-any.whl -
Subject digest:
f44fac07f525dff897cc4862a16cde51a3bc8f114265796b1f2716ef96c648c7 - Sigstore transparency entry: 1797967137
- Sigstore integration time:
-
Permalink:
guolong123/jcli@12cbf354bd7d249d63e1c46fd6f12a6c5f6d199f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/guolong123
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@12cbf354bd7d249d63e1c46fd6f12a6c5f6d199f -
Trigger Event:
release
-
Statement type: