{"id":347,"date":"2026-10-13T18:11:26","date_gmt":"2026-10-13T18:11:26","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/2014\/02\/10\/know-about-jenkins-cli-2\/"},"modified":"2026-10-13T18:11:26","modified_gmt":"2026-10-13T18:11:26","slug":"know-about-jenkins-cli-2","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/know-about-jenkins-cli-2\/","title":{"rendered":"Jenkins CLI Reference: Setup, Authentication, and Practical Command Examples"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Originally published on 2014-02-10; fully revised and updated.<\/em><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2014\/02\/jenkins-cli-1.png\" alt=\"Jenkins CLI overview\"\/><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\">What Jenkins CLI is useful for<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Triggering builds with parameters<\/li><li>Reading build logs and job metadata<\/li><li>Creating, copying, and updating jobs from configuration XML<\/li><li>Managing nodes, queue state, and restart\/shutdown operations<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Download the matching jenkins-cli.jar from your Jenkins server<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The original guidance is still valid: download the CLI JAR from <a href=\"http:\/\/yourserver.com\/cli\">your own Jenkins \/cli endpoint<\/a> so the CLI matches your server version. Jenkins typically exposes the file at <a href=\"http:\/\/yourserver.com\/jnlpJars\/jenkins-cli.jar\">\/jnlpJars\/jenkins-cli.jar<\/a>.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php language-bash\"><span class=\"hljs-comment\"># Check CLI page in a browser<\/span>\nhttp:<span class=\"hljs-comment\">\/\/yourserver.com\/cli<\/span>\n\n<span class=\"hljs-comment\"># Download the matching jar from your Jenkins controller<\/span>\ncurl -O http:<span class=\"hljs-comment\">\/\/yourserver.com\/jnlpJars\/jenkins-cli.jar<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Basic command format and help<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">General syntax and help commands from the original article are below. Use these first when validating connectivity and permissions.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript language-bash\">java -jar jenkins-cli.jar &#91;-s JENKINS_URL] command &#91;options...] &#91;<span class=\"hljs-built_in\">arguments<\/span>...]\n\njava -jar jenkins-cli.jar -s http:<span class=\"hljs-comment\">\/\/yourserver.com help<\/span>\njava -jar jenkins-cli.jar -s http:<span class=\"hljs-comment\">\/\/yourserver.com help build<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Authentication options for secured Jenkins<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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 <code>login<\/code>\/<code>logout<\/code>.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Method<\/th><th>Command pattern<\/th><th>Best for<\/th><th>Operational note<\/th><\/tr><\/thead><tbody><tr><td>Username and password<\/td><td><code>--username USER --password PASS<\/code><\/td><td>Quick manual checks<\/td><td>Credentials can be exposed in shell history\/process lists.<\/td><\/tr><tr><td>SSH private key<\/td><td><code>-i ~\/.ssh\/id_rsa<\/code><\/td><td>User accounts configured with Jenkins SSH public keys<\/td><td>Requires correct key setup on the Jenkins user account.<\/td><\/tr><tr><td>Cached CLI credential<\/td><td><code>login<\/code> then future commands<\/td><td>Repeated local CLI sessions<\/td><td>Credential storage behavior depends on local environment and Jenkins setup.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript language-bash\">java -jar jenkins-cli.jar -s http:<span class=\"hljs-comment\">\/\/myjenkins help --username me --password mypassword<\/span>\njava -jar jenkins-cli.jar -s http:<span class=\"hljs-comment\">\/\/myjenkins help -i ~\/.ssh\/id_rsa<\/span>\n\njava -jar jenkins-cli.jar -s http:<span class=\"hljs-comment\">\/\/myjenkins login --username me --password mypassword<\/span>\njava -jar jenkins-cli.jar -s http:<span class=\"hljs-comment\">\/\/myjenkins who-am-i<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Jenkins CLI command workflow<\/h2>\n\n\n\n<pre class=\"mermaid\">\nflowchart TD\n    A[Set Jenkins URL] --> B[Download jenkins-cli.jar from server]\n    B --> C[Run help command]\n    C --> D{Jenkins secured}\n    D -- no --> G[Run target command]\n    D -- yes with user pass --> E[Authenticate with username password]\n    D -- yes with SSH key --> F[Authenticate with private key]\n    E --> G\n    F --> G\n    G --> H[Review output and exit status]\n    H --> I[Adjust permissions or command flags]\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Common Jenkins CLI commands by task<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The original post includes a long command inventory. In practice, these are high-frequency commands that cover most daily automation and admin workflows.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Task<\/th><th>Command<\/th><th>Example<\/th><\/tr><\/thead><tbody><tr><td>Trigger a job<\/td><td><code>build<\/code><\/td><td><code>java -jar jenkins-cli.jar -s http:\/\/myjenkins build \"my-job\"<\/code><\/td><\/tr><tr><td>Read console logs<\/td><td><code>console<\/code><\/td><td><code>java -jar jenkins-cli.jar -s http:\/\/myjenkins console \"my-job\" 42<\/code><\/td><\/tr><tr><td>List jobs<\/td><td><code>list-jobs<\/code><\/td><td><code>java -jar jenkins-cli.jar -s http:\/\/myjenkins list-jobs<\/code><\/td><\/tr><tr><td>Export job config<\/td><td><code>get-job<\/code><\/td><td><code>java -jar jenkins-cli.jar -s http:\/\/myjenkins get-job \"my-job\"<\/code><\/td><\/tr><tr><td>Update job config<\/td><td><code>update-job<\/code><\/td><td><code>java -jar jenkins-cli.jar -s http:\/\/myjenkins update-job \"my-job\"<\/code><\/td><\/tr><tr><td>Check identity and perms<\/td><td><code>who-am-i<\/code><\/td><td><code>java -jar jenkins-cli.jar -s http:\/\/myjenkins who-am-i<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Trigger a parameterized build<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To pass build parameters via CLI, add one <code>-p key=value<\/code> for each parameter.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript language-bash\">java -jar jenkins-cli.jar -s http:<span class=\"hljs-comment\">\/\/myjenkins build \"Deploy XYZ App\" -i ~\/.ssh\/id_rsa -p target_env=api.cloudfoundry.com -p branch=master<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Manage job XML from the terminal<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">These commands support export-edit-apply workflows for job definitions.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php language-bash\"><span class=\"hljs-comment\"># Export a job config to file<\/span>\njava -jar jenkins-cli.jar -s http:<span class=\"hljs-comment\">\/\/myjenkins get-job \"my-job\" &gt; my-job.xml<\/span>\n\n<span class=\"hljs-comment\"># Update a job config from file<\/span>\njava -jar jenkins-cli.jar -s http:<span class=\"hljs-comment\">\/\/myjenkins update-job \"my-job\" &lt; my-job.xml<\/span>\n\n<span class=\"hljs-comment\"># Create a new job from XML<\/span>\njava -jar jenkins-cli.jar -s http:<span class=\"hljs-comment\">\/\/myjenkins create-job \"my-new-job\" &lt; my-job.xml<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">How to discover all commands on your own Jenkins<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Because available commands can vary by Jenkins version and installed plugins, always inspect your own server output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript language-bash\">java -jar jenkins-cli.jar -s http:<span class=\"hljs-comment\">\/\/yourserver.com help<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Reference links from the original post<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/wiki.jenkins-ci.org\/display\/JENKINS\/Jenkins+CLI\">https:\/\/wiki.jenkins-ci.org\/display\/JENKINS\/Jenkins+CLI<\/a><\/li><li><a href=\"http:\/\/stackoverflow.com\/questions\/18199355\/jenkins-cli-authentication\">http:\/\/stackoverflow.com\/questions\/18199355\/jenkins-cli-authentication<\/a><\/li><li><a href=\"http:\/\/stackoverflow.com\/questions\/16617232\/jenkins-cli-public-key-authentication-where-to-put-my-public-key-in-jenkins\">http:\/\/stackoverflow.com\/questions\/16617232\/jenkins-cli-public-key-authentication-where-to-put-my-public-key-in-jenkins<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Best practices<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Download <code>jenkins-cli.jar<\/code> from the same Jenkins server you target.<\/li><li>Validate access with <code>help<\/code> and <code>who-am-i<\/code> before running admin commands.<\/li><li>Prefer key-based authentication where possible, and avoid exposing secrets in shell history.<\/li><li>Treat restart\/shutdown commands as change-controlled operations in production environments.<\/li><li>Generate command lists from your server because command availability can change across versions and plugins.<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Jenkins CLI helps you automate administrative and build operations from the terminal. This updated reference covers setup, authentication choices, and high-value commands with copy-ready examples.<\/p>\n","protected":false},"author":1,"featured_media":3751,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[42],"tags":[2308,829,824,145,2306,2309,2312,2311,2310,826,2307],"class_list":["post-347","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jenkins","tag-about-jenkins-cli","tag-cli","tag-command-line","tag-jenkins","tag-jenkins-cli","tag-jenkins-cli-guide","tag-jenkins-cli-instructions","tag-jenkins-cli-reference","tag-jenkins-cli-tutorial","tag-jenkins-command-line","tag-understand-jenkins-cli"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/347","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=347"}],"version-history":[{"count":3,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/347\/revisions"}],"predecessor-version":[{"id":79217,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/347\/revisions\/79217"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/3751"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}