{"id":346,"date":"2026-10-13T18:01:06","date_gmt":"2026-10-13T18:01:06","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/2014\/02\/10\/know-about-jenkins-cli\/"},"modified":"2026-10-13T18:01:06","modified_gmt":"2026-10-13T18:01:06","slug":"know-about-jenkins-cli","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/know-about-jenkins-cli\/","title":{"rendered":"Jenkins CLI Guide: Download, Authenticate, and Automate Jobs from the Terminal"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Jenkins CLI lets you run Jenkins operations from a terminal, which is useful for automation scripts, repeatable admin tasks, and quick troubleshooting. This guide shows how to get the correct CLI JAR, authenticate against secured Jenkins, trigger parameterized builds, and work with high-value commands.<\/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\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2014\/02\/jenkins-cli.png\" alt=\"Jenkins CLI\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Get the matching jenkins-cli.jar from your Jenkins server<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The safest way to get <code>jenkins-cli.jar<\/code> is from your own Jenkins instance so the CLI version matches the server. Open your Jenkins <code>\/cli<\/code> page (for example, <code>http:\/\/yourserver.com\/cli<\/code>) and download the JAR from the link it provides (typically under <code>\/jnlpJars\/jenkins-cli.jar<\/code>).<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css language-bash\"><span class=\"hljs-selector-tag\">java<\/span> <span class=\"hljs-selector-tag\">-jar<\/span> <span class=\"hljs-selector-tag\">jenkins-cli<\/span><span class=\"hljs-selector-class\">.jar<\/span> <span class=\"hljs-selector-attr\">&#91;-s JENKINS_URL]<\/span> <span class=\"hljs-selector-tag\">command<\/span> <span class=\"hljs-selector-attr\">&#91;options...]<\/span> <span class=\"hljs-selector-attr\">&#91;arguments...]<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Run help and discover commands on your server<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Command availability can vary by Jenkins version and installed plugins, so always query your own server.<\/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 -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<p class=\"wp-block-paragraph\">You can also browse command documentation from <a href=\"http:\/\/yourserver.com\/cli\">http:\/\/yourserver.com\/cli<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Authenticate to a secured Jenkins<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The original guide shows two common approaches for secured Jenkins: pass username\/password each time, or use an SSH private key with <code>-i<\/code>.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Authentication method<\/th><th>Example<\/th><th>Best for<\/th><\/tr><\/thead><tbody><tr><td>Username and password flags<\/td><td><code>--username me --password mypassword<\/code><\/td><td>Quick manual checks<\/td><\/tr><tr><td>SSH private key<\/td><td><code>-i ~\/.ssh\/id_rsa<\/code><\/td><td>Reusable automation with key-based auth<\/td><\/tr><tr><td>Saved CLI credential<\/td><td><code>login<\/code> and <code>logout<\/code> commands<\/td><td>Reducing repeated credential flags in interactive usage<\/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><\/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\">Trigger parameterized builds from the CLI<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">For parameterized jobs, pass each build parameter with <code>-p key=value<\/code>.<\/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 -s -v -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<h2 class=\"wp-block-heading\">Jenkins CLI workflow<\/h2>\n\n\n\n<pre class=\"mermaid\">\nflowchart TD\n    A[Open Jenkins cli endpoint] --> B[Download matching jenkins cli jar]\n    B --> C[Run help command]\n    C --> D{Server secured}\n    D -- yes --> E[Authenticate with user pass or ssh key]\n    D -- no --> F[Run command directly]\n    E --> G[Execute build or admin command]\n    F --> G\n    G --> H[Review output and build logs]\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Commonly used Jenkins CLI commands<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The original post listed many commands. The table below highlights practical commands teams use frequently.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Command<\/th><th>What it does<\/th><th>Typical use<\/th><\/tr><\/thead><tbody><tr><td><code>build<\/code><\/td><td>Triggers a job build<\/td><td>CI\/CD automation from scripts<\/td><\/tr><tr><td><code>console<\/code><\/td><td>Gets build console output<\/td><td>Triage failed runs quickly<\/td><\/tr><tr><td><code>list-jobs<\/code><\/td><td>Lists jobs in a view or group<\/td><td>Inventory and audit scripts<\/td><\/tr><tr><td><code>get-job<\/code> \/ <code>update-job<\/code><\/td><td>Exports or updates job XML<\/td><td>Bulk job maintenance<\/td><\/tr><tr><td><code>create-job<\/code> \/ <code>delete-job<\/code><\/td><td>Creates or removes jobs<\/td><td>Provisioning and cleanup<\/td><\/tr><tr><td><code>list-plugins<\/code> \/ <code>install-plugin<\/code><\/td><td>Inspects or installs plugins<\/td><td>Plugin management<\/td><\/tr><tr><td><code>quiet-down<\/code>, <code>safe-restart<\/code>, <code>safe-shutdown<\/code><\/td><td>Controls server state safely<\/td><td>Maintenance windows<\/td><\/tr><tr><td><code>who-am-i<\/code><\/td><td>Shows identity and permissions<\/td><td>Auth and RBAC troubleshooting<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" 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 get-job my-job &gt; my-job.xml<\/span>\njava -jar jenkins-cli.jar -s http:<span class=\"hljs-comment\">\/\/yourserver.com update-job my-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\">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\">Original references and further reading<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/wiki.jenkins-ci.org\/display\/JENKINS\/Jenkins+CLI\">Jenkins CLI reference (legacy Jenkins wiki link from original post)<\/a><\/li><li><a href=\"http:\/\/stackoverflow.com\/questions\/18199355\/jenkins-cli-authentication\">Stack Overflow: 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\">Stack Overflow: Jenkins CLI public key authentication<\/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>Always download <code>jenkins-cli.jar<\/code> from the same Jenkins server you are targeting.<\/li><li>Prefer key-based authentication for automation and avoid hard-coding credentials in scripts.<\/li><li>Use <code>help<\/code> on your server before scripting commands, because CLI capabilities can differ by version.<\/li><li>Use safe operations (<code>quiet-down<\/code>, <code>safe-restart<\/code>, <code>safe-shutdown<\/code>) during maintenance to avoid interrupting active builds.<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to use Jenkins CLI to run builds, administer jobs, and script Jenkins operations without the web UI. This updated guide covers setup, authentication, command discovery, and practical examples.<\/p>\n","protected":false},"author":1,"featured_media":3748,"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-346","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\/346","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=346"}],"version-history":[{"count":3,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/346\/revisions"}],"predecessor-version":[{"id":79216,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/346\/revisions\/79216"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/3748"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=346"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=346"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=346"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}