Jenkins CLI lets administrators and DevOps engineers run Jenkins operations from a terminal instead of clicking through the web UI. This guide explains how to download the matching CLI JAR from your Jenkins server, authenticate on secured instances, and use common commands for builds, jobs, and troubleshooting.
Originally published on 2014-02-10; fully revised and updated.

What Jenkins CLI is useful for
Jenkins CLI is a command-line interface for interacting with a Jenkins controller. It is especially useful when you want repeatable admin operations in scripts, quick access over SSH sessions, or bulk updates that are slower in the UI.
- Triggering builds with parameters
- Reading build logs and job metadata
- Creating, copying, and updating jobs from configuration XML
- Managing nodes, queue state, and restart/shutdown operations
Download the matching jenkins-cli.jar from your Jenkins server
The original guidance is still valid: download the CLI JAR from your own Jenkins /cli endpoint so the CLI matches your server version. Jenkins typically exposes the file at /jnlpJars/jenkins-cli.jar.
# Check CLI page in a browser
http://yourserver.com/cli
# Download the matching jar from your Jenkins controller
curl -O http://yourserver.com/jnlpJars/jenkins-cli.jarCode language: PHP (php)
Basic command format and help
General syntax and help commands from the original article are below. Use these first when validating connectivity and permissions.
java -jar jenkins-cli.jar [-s JENKINS_URL] command [options...] [arguments...]
java -jar jenkins-cli.jar -s http://yourserver.com help
java -jar jenkins-cli.jar -s http://yourserver.com help buildCode language: JavaScript (javascript)
Authentication options for secured Jenkins
On secured Jenkins instances, unauthenticated commands may fail. The original post shows two direct methods (username/password and SSH private key), plus Jenkins CLI also supports credential caching via login/logout.
| Method | Command pattern | Best for | Operational note |
|---|---|---|---|
| Username and password | --username USER --password PASS | Quick manual checks | Credentials can be exposed in shell history/process lists. |
| SSH private key | -i ~/.ssh/id_rsa | User accounts configured with Jenkins SSH public keys | Requires correct key setup on the Jenkins user account. |
| Cached CLI credential | login then future commands | Repeated local CLI sessions | Credential storage behavior depends on local environment and Jenkins setup. |
java -jar jenkins-cli.jar -s http://myjenkins help --username me --password mypassword
java -jar jenkins-cli.jar -s http://myjenkins help -i ~/.ssh/id_rsa
java -jar jenkins-cli.jar -s http://myjenkins login --username me --password mypassword
java -jar jenkins-cli.jar -s http://myjenkins who-am-iCode language: JavaScript (javascript)
Jenkins CLI command workflow
flowchart TD
A[Set Jenkins URL] --> B[Download jenkins-cli.jar from server]
B --> C[Run help command]
C --> D{Jenkins secured}
D -- no --> G[Run target command]
D -- yes with user pass --> E[Authenticate with username password]
D -- yes with SSH key --> F[Authenticate with private key]
E --> G
F --> G
G --> H[Review output and exit status]
H --> I[Adjust permissions or command flags]
Common Jenkins CLI commands by task
The original post includes a long command inventory. In practice, these are high-frequency commands that cover most daily automation and admin workflows.
| Task | Command | Example |
|---|---|---|
| Trigger a job | build | java -jar jenkins-cli.jar -s http://myjenkins build "my-job" |
| Read console logs | console | java -jar jenkins-cli.jar -s http://myjenkins console "my-job" 42 |
| List jobs | list-jobs | java -jar jenkins-cli.jar -s http://myjenkins list-jobs |
| Export job config | get-job | java -jar jenkins-cli.jar -s http://myjenkins get-job "my-job" |
| Update job config | update-job | java -jar jenkins-cli.jar -s http://myjenkins update-job "my-job" |
| Check identity and perms | who-am-i | java -jar jenkins-cli.jar -s http://myjenkins who-am-i |
Trigger a parameterized build
To pass build parameters via CLI, add one -p key=value for each parameter.
java -jar jenkins-cli.jar -s http://myjenkins build "Deploy XYZ App" -i ~/.ssh/id_rsa -p target_env=api.cloudfoundry.com -p branch=masterCode language: JavaScript (javascript)
Manage job XML from the terminal
These commands support export-edit-apply workflows for job definitions.
# Export a job config to file
java -jar jenkins-cli.jar -s http://myjenkins get-job "my-job" > my-job.xml
# Update a job config from file
java -jar jenkins-cli.jar -s http://myjenkins update-job "my-job" < my-job.xml
# Create a new job from XML
java -jar jenkins-cli.jar -s http://myjenkins create-job "my-new-job" < my-job.xmlCode language: PHP (php)
How to discover all commands on your own Jenkins
Because available commands can vary by Jenkins version and installed plugins, always inspect your own server output:
java -jar jenkins-cli.jar -s http://yourserver.com helpCode language: JavaScript (javascript)
Reference links from the original post
- https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+CLI
- http://stackoverflow.com/questions/18199355/jenkins-cli-authentication
- http://stackoverflow.com/questions/16617232/jenkins-cli-public-key-authentication-where-to-put-my-public-key-in-jenkins
Best practices
- Download
jenkins-cli.jarfrom the same Jenkins server you target. - Validate access with
helpandwho-am-ibefore running admin commands. - Prefer key-based authentication where possible, and avoid exposing secrets in shell history.
- Treat restart/shutdown commands as change-controlled operations in production environments.
- Generate command lists from your server because command availability can change across versions and plugins.
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services — all in one place.
Explore Hospitals