<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jenkins Command line Archives - scmGalaxy</title>
	<atom:link href="https://www.scmgalaxy.com/tutorials/tag/jenkins-command-line/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.scmgalaxy.com/tutorials/tag/jenkins-command-line/</link>
	<description>A Platform for Software Engineers</description>
	<lastBuildDate>Sat, 27 Feb 2021 09:52:49 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1</generator>
	<item>
		<title>Complete guide to use Jenkins CLI / Command line &#124; Jenkins Tutorials</title>
		<link>https://www.scmgalaxy.com/tutorials/complete-guide-to-use-jenkins-cli-command-line/</link>
					<comments>https://www.scmgalaxy.com/tutorials/complete-guide-to-use-jenkins-cli-command-line/#comments</comments>
		
		<dc:creator><![CDATA[scmgalaxy K]]></dc:creator>
		<pubDate>Sun, 08 Jan 2017 08:37:19 +0000</pubDate>
				<category><![CDATA[Jenkins]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[CLI / Command line]]></category>
		<category><![CDATA[Command line]]></category>
		<category><![CDATA[Jenkins CLI / Command line]]></category>
		<category><![CDATA[Jenkins Command line]]></category>
		<category><![CDATA[Jenkins Command line Guide]]></category>
		<category><![CDATA[Jenkins Command line Tutorials]]></category>
		<category><![CDATA[Jenkins Tutorials]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/2017/01/08/complete-guide-to-use-jenkins-cli-command-line/</guid>

					<description><![CDATA[<p>Complete guide to use Jenkins CLI / Command line? Run Jenkins build from command is very simple in Linux system. [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/complete-guide-to-use-jenkins-cli-command-line/">Complete guide to use Jenkins CLI / Command line | Jenkins Tutorials</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img fetchpriority="high" decoding="async" class="size-full wp-image-2959 aligncenter" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/complete-guide-to-use-jenki.png" alt="jenkins-cli-command-line" width="600" height="400" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/complete-guide-to-use-jenki.png 600w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/complete-guide-to-use-jenki-300x200.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></div>
<div>Complete guide to use Jenkins CLI / Command line?</div>
<div></div>
<div>Run Jenkins build from command is very simple in Linux system. If you are using using windows, gitbash is a recommended which has bash shell in built. You can use windows command line as well. Jenkins has support to command line client that allows you to access Jenkins from command line.</div>
<div></div>
<div><strong>To Trigger Jenkins build from command line some prerequisite are there</strong></div>
<div></div>
<div>Jenkins service is running.</div>
<div>Enable security option under “Configure Global Security”</div>
<div></div>
<div>Go to jenkins dashboard in Home page ( e.g http://localhost:8080/ ) -&gt; Manage Jenkins</div>
<div>-&gt; Configure Global Security -&gt; Click on “Enable security” checkbox</div>
<div></div>
<div>
<p>You can also configure “Access Control” and “Authorization” option in Global Security page.</p>
<div><strong>Download Jenkins-cli.jar</strong></div>
<div>Download Jenkins-cli.jar from http://&lt;your_jenkins_server_url&gt;/jnlpJars/jenkins-cli.jar. (Here &lt;your_jenkins_server_url&gt; is your respective Jenkins server URL (development or staging))</div>
<div>Go to http://&lt;your_jenkins_server_url&gt;/cli and build your command by following the instructions there.</div>
</div>
<div></div>
<div><strong>How to login to Jenkins using commands</strong></div>
<div>If your Jenkins requires authentication, use &#8211;username and &#8211;password or &#8211;password-file options to specify the credentials. To avoid doing this for every command, you can also use the login CLI command once (with the same credentials parameters), and after that you may use other commands without specifying credentials.</div>
<div></div>
<div>Whenever the CLI tries to to connect to the Jenkins server, it offers the before mentioned SSH keys. When the user has those keys but don&#8217;t want use them to authenticate, preventing being prompted by the key&#8217;s password, it&#8217;s possible to use the -noKeyAuth argument. This way the CLI will never try to use the SSH keys available. failure to authenticate by itself does not constitute a fatal error. It will instead try to execute the command anyway, as the anonymous user.</div>
<div></div>
<div></div>
<div><strong>Login Jenkins using username and Password</strong></div>
<div>Jenkins allow us to trigger Jenkins build with any specific user, For that we have to pass username and password in command line.</div>
<div>$ java -jar &#8220;/tmp/kitchen/cache/jenkins-cli.jar&#8221; -s http://localhost:8080 who-am-i &#8211;username jenkins &#8211;password foobar</div>
<div>$ java -jar jenkins-cli.jar -s http://myjenkins help &#8211;username me &#8211;password mypassword</div>
<div></div>
<div><strong>Login Jenkins using public keys</strong></div>
<div>Starting 1.419 (which will be out July 4th), Jenkins CLI supports authentication based on the SSH key pair. Just like CloudBees DEV@cloud (or GitHub, or other similar sites), you interactively login from the web UI, then associate your public keys with your user account. Then CLI will silently authenticates itself using your ~/.ssh/id_rsa, ~/.ssh/id_dsa, or ~/.ssh/identity.</div>
<div>https://help.github.com/articles/generating-an-ssh-key/</div>
<div></div>
<div><strong>Login Jenkins using private keys</strong></div>
<div>You can also pass the priate key as follows</div>
<div>To use the -i option the syntax is as follows:</div>
<div>$ java -jar jenkins-cli.jar -s http://myjenkins help -i ~/.ssh/id_rsa</div>
<div>$ java -jar jenkins-cli.jar [-s JENKINS_URL] [-i PRIVATE_KEY] command [options&#8230;] [arguments&#8230;]</div>
<div>For compatibility reasons, unless you use the -i option,</div>
<div></div>
<div><strong>Login Jenkins using initialAdminPassword</strong></div>
<div>try user &#8220;admin&#8221; and password from &#8220;Jenkins\secrets\initialAdminPassword&#8221;</div>
<div>java -jar jenkins-cli.jar -s http://localhost:8080 who-am-i &#8211;username admin &#8211;password fe3f1e1624ea4be8873b7a35e28b24be</div>
<div></div>
<div><strong>Login Jenkins using passphrase</strong></div>
<div>Go to http://jenkins-serer:8085/user/admin/configure and set the passphrase in &#8220;SSH Public Keys&#8221; and use the same passphrase with jenkins commands.</div>
<div></div>
<div><strong>E.g 1 &#8211; Getting help</strong></div>
<div>The list of the available commands depends on the server you are talking to. Visit https://jenkins.example.com/cli or use &#8216;help&#8217; command to list them all:</div>
<div>&gt; java -jar jenkins-cli.jar -s https://jenkins.example.com help [command]</div>
<div></div>
<div><strong>E.g 2 &#8211; Run Jenkins Build From Command Line</strong></div>
<div>&gt; java -jar jenkins-cli.jar -s http://&lt;jenkins server&gt;/ build build-name [-c] [-f] [-p] [-r N] [-s] [-v] [-w]</div>
<div></div>
<div>build-name : Name of the job to build</div>
<div>-c  : Check for SCM changes before starting the build, and if there&#8217;s no change, exit without doing a build</div>
<div>-f  : Follow the build progress. Like -s only interrupts are not passed through to the build.</div>
<div>-p  : Specify the build parameters in the key=value format.</div>
<div>-s  : Wait until the completion/abortion of the command. Interrupts are passed through to the build.</div>
<div>-v  : Prints out the console output of the build. Use with -s</div>
<div>-w  : Wait until the start of the command</div>
<div></div>
<div>Example  &#8211; java -jar jenkins-cli.jar -s http://localhost:8080/ build &#8216;my-project-build&#8217; &#8211;username roop &#8211;password roop</div>
<div></div>
<div><strong>E.g 3 &#8211; List all jobs under the view: tools</strong></div>
<div>$ java -jar jenkins-cli.jar -s http://jenkins/ list-jobs tools</div>
<div></div>
<div><strong>E.g 4 &#8211; Get the configuration of the job: template</strong></div>
<div>$ java -jar jenkins-cli.jar -s http://jenkins/ get-job template &gt; template.xml</div>
<div></div>
<div><strong>E.g 5 &#8211; Create a new job based on the configuration</strong></div>
<div>$ java -jar jenkins-cli.jar -s http://jenkins/ create-job new_job_name &lt; new_job_name.xml</div>
<div></div>
<div><strong>E.g 6 &#8211; Run groovy script</strong></div>
<div>$ java -jar jenkins-cli.jar -s http://jenkins/ groovy scripts/add_job_to_view.groovy</div>
<div>If there are any parameters in the script, just as:</div>
<div>import jenkins.model.*</div>
<div></div>
<div>if (args.length != 2 ) {</div>
<div>  println &#8220;Error on arguments!&#8221;</div>
<div>}</div>
<div>def jobName  = args[0] ?: &#8216;a_job&#8217;</div>
<div>def viewName = args[1] ?: &#8216;a_view&#8217;</div>
<div></div>
<div>println jobName + &#8216; &#8216; + viewName</div>
<div></div>
<div>def v = Jenkins.instance.getView(viewName)</div>
<div>def i = Jenkins.instance.getItemByFullName(jobName)</div>
<div>if (v &amp;&amp; i) {</div>
<div>  v.add(i)</div>
<div>}</div>
<div></div>
<div>pass the parameters as:</div>
<div></div>
<div>$ java -jar jenkins-cli.jar -s http://jenkins/ groovy scripts/add_job_to_view.groovy JOB_NAME VIEM_NAME</div>
<div></div>
<div><strong>E.g 7 &#8211; Build a job</strong></div>
<div>$ java -jar jenkins-cli.jar -s http://jenkins/ build new_job_name</div>
<div></div>
<div><strong>E.g 8 &#8211; Diable a job</strong></div>
<div>$ java -jar jenkins-cli.jar -s http://jenkins/ disable-job new_job_name</div>
<div></div>
<div><strong>E.g 8 &#8211; Passing parameters when triggering a job build</strong></div>
<div>Job parameters are a very handy concept. Perhaps you&#8217;ve only ever used Jenkins or another CI system to automatically run builds when a remote SCM/git repo changes. You can also trigger builds manually from within Jenkins. And whilst you&#8217;re doing that, your job can prompt for parameters to the build.</div>
<div></div>
<div>For example, we have a job named similar to &#8220;Deploy XYZ App&#8221;. It has the git repo hardcoded in the job like a normal build, but when you press &#8220;Build&#8221;, it shows a list of options: string fields, drop-down lists, etc.</div>
<div></div>
<div>When the job runs, you can use these values anywhere within your job&#8217;s configuration. Its very cool.</div>
<div></div>
<div>But how to pass those same parameters via the CLI? You use the -p key=value flag for each parameter you want to pass.</div>
<div></div>
<div>So our finished product might look like:</div>
<div>$ java -jar jenkins-cli.jar -s http://myjenkins build &#8216;Deploy XYZ App&#8217; -i ~/.ssh/id_rsa -s -v -p target_env=api.cloudfoundry.com -p branch=master</div>
<div></div>
<div><strong>Commons problems</strong></div>
<div>Operation timed out</div>
<div>$ java -jar jenkins-cli.jar -s YOUR_SERVER_URL help</div>
<div>Exception in thread &#8220;main&#8221; java.net.ConnectException: Operation timed out</div>
<div>at java.net.PlainSocketImpl.socketConnect(Native Method)</div>
<div>at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)</div>
<div>at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)</div>
<div>at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)</div>
<div>at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)</div>
<div>at java.net.Socket.connect(Socket.java:529)</div>
<div>at java.net.Socket.connect(Socket.java:478)</div>
<div>at java.net.Socket.&lt;init&gt;(Socket.java:375)</div>
<div>at java.net.Socket.&lt;init&gt;(Socket.java:189)</div>
<div>at hudson.cli.CLI.&lt;init&gt;(CLI.java:97)</div>
<div>at hudson.cli.CLI.&lt;init&gt;(CLI.java:82)</div>
<div>at hudson.cli.CLI._main(CLI.java:250)</div>
<div>at hudson.cli.CLI.main(CLI.java:199)</div>
<div>Check that the JNLP port is opened if you are using a firewall on your server. You can configure its value in Jenkins configuration. By default it is set to use a random port.</div>
<div></div>
<div>java.io.IOException: No X-Jenkins-CLI2-Port</div>
<div>java.io.IOException: No X-Jenkins-CLI2-Port among [X-Jenkins, null, Server, X-Content-Type-Options, Connection, X-You-Are-In-Group, X-Hudson, X-Permission-Implied-By, Date, X-Jenkins-Session, X-You-Are-Authenticated-As, X-Required-Permission, Set-Cookie, Expires, Content-Length, Content-Type]</div>
<div>at hudson.cli.CLI.getCliTcpPort(CLI.java:284)</div>
<div>at hudson.cli.CLI.&lt;init&gt;(CLI.java:128)</div>
<div>at hudson.cli.CLIConnectionFactory.connect(CLIConnectionFactory.java:72)</div>
<div>at hudson.cli.CLI._main(CLI.java:473)</div>
<div>at hudson.cli.CLI.main(CLI.java:384)</div>
<div>Suppressed: java.io.IOException: Server returned HTTP response code: 403 for URL: <a href="http://citest.gce.px/cli" target="_blank" rel="noopener">http://citest.gce.px/cli</a></div>
<div>at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1840)</div>
<div>at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)</div>
<div>at hudson.cli.FullDuplexHttpStream.&lt;init&gt;(FullDuplexHttpStream.java:78)</div>
<div>at hudson.cli.CLI.connectViaHttp(CLI.java:152)</div>
<div>at hudson.cli.CLI.&lt;init&gt;(CLI.java:132)</div>
<div>&#8230; 3 more</div>
<div>Solution: Go to Manage Jenkins -&gt; Configure Global Security -&gt; &#8220;TCP port for JNLP agents&#8221;: choose fixed or random</div>
<div></div>
<div><strong>Reference</strong></div>
<div><a href="https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+CLI" target="_blank" rel="noopener">https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+CLI</a></div>
<div><a href="http://lifuzu.com/blog/2014/04/24/playing-with-jenkins-create-job/" target="_blank" rel="noopener">http://lifuzu.com/blog/2014/04/24/playing-with-jenkins-create-job/</a></div>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/complete-guide-to-use-jenkins-cli-command-line/">Complete guide to use Jenkins CLI / Command line | Jenkins Tutorials</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/complete-guide-to-use-jenkins-cli-command-line/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Jenkins Command line Reference for login and trigger a job</title>
		<link>https://www.scmgalaxy.com/tutorials/jenkins-command-line-reference-for-login-and-trigger-a-job/</link>
					<comments>https://www.scmgalaxy.com/tutorials/jenkins-command-line-reference-for-login-and-trigger-a-job/#comments</comments>
		
		<dc:creator><![CDATA[scmgalaxy K]]></dc:creator>
		<pubDate>Thu, 05 Feb 2015 00:00:00 +0000</pubDate>
				<category><![CDATA[Jenkins]]></category>
		<category><![CDATA[Command line]]></category>
		<category><![CDATA[How]]></category>
		<category><![CDATA[How to login in Jenkins]]></category>
		<category><![CDATA[How to trigger a job in Jenkins]]></category>
		<category><![CDATA[Jenkins Command line]]></category>
		<category><![CDATA[Jenkins Command line Guide]]></category>
		<category><![CDATA[Jenkins Command line Reference]]></category>
		<category><![CDATA[Jenkins Command line Tutorial]]></category>
		<category><![CDATA[job]]></category>
		<category><![CDATA[Login]]></category>
		<category><![CDATA[Login Jenkins]]></category>
		<category><![CDATA[Process]]></category>
		<category><![CDATA[Reference]]></category>
		<category><![CDATA[Steps]]></category>
		<category><![CDATA[Trigger]]></category>
		<category><![CDATA[Ways]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/2015/02/05/jenkins-command-line-reference-for-login-and-trigger-a-job/</guid>

					<description><![CDATA[<p>Grep will return 0 while the build is running: $ curl http://myjenkins/job/myjob/lastBuild/api/json &#124; grep &#8211;color result\&#8221;:null $ echo $? Trigger [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/jenkins-command-line-reference-for-login-and-trigger-a-job/">Jenkins Command line Reference for login and trigger a job</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img decoding="async" class="alignnone size-full wp-image-3535 aligncenter" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2015/02/jenkins-command-line-refere.png" alt="jenkins-command-line-reference" width="600" height="400" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2015/02/jenkins-command-line-refere.png 600w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2015/02/jenkins-command-line-refere-300x200.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></p>
<p><b>Grep will return 0 while the build is running:</b></p>
<p>$ curl http://myjenkins/job/myjob/lastBuild/api/json | grep &#8211;color result\&#8221;:null</p>
<p>$ echo $?</p>
<p><strong>Trigger a Jenkins Job from command line</strong></p>
<p>$ wget http://yourserver/job/MyJobname/build?delay=0sec</p>
<p>$ wget -O &#8211; $HUDSON_URL/job/JOBNAME/build</p>
<p><strong>Trigger a Jenkins Job without authentication</strong></p>
<p>$ curl http://jenkins:8080/job/my%20job/build</p>
<p><strong>Trigger a Jenkins Job with authentication</strong></p>
<p>$ curl &#8211;user dbacher:$MY_API_TOKEN http://jenkins:8080/job/my%20job/build</p>
<p>$ curl &#8211;user &lt;your_jenkins_username&gt;:&lt;your_jenkins_API_key&gt; http://&lt;jenkins_server_url&gt;/job/&lt;your_jenkins_job_name&gt;/build</p>
<p><strong>Running commands against a secure Jenkins (basic auth or ssh keys)</strong></p>
<p>$ java -jar jenkins-cli.jar -s http://myjenkins help &#8211;username me &#8211;password mypassword</p>
<p>$ java -jar jenkins-cli.jar -s http://myjenkins help -i ~/.ssh/id_rsa</p>
<p><strong>Triggering a job build against a secure Jenkins (avoiding a 1.5 year old open bug!)</strong></p>
<p>$ java -jar jenkins-cli.jar -s http://myjenkins build &#8216;My Awesome Jenkins Job&#8217; -i ~/.ssh/id_rsa</p>
<p>$ java -jar jenkins-cli.jar -s http://myjenkins build &#8216;My Awesome Jenkins Job&#8217; -i ~/.ssh/id_rsa -s -v</p>
<p><strong>Passing parameters when triggering a job build</strong></p>
<p>$ java -jar jenkins-cli.jar -s http://myjenkins build &#8216;Deploy XYZ App&#8217; -i ~/.ssh/id_rsa -s -v -p target_env=api.cloudfoundry.com -p branch=master</p>
<p><strong>Reference</strong></p>
<p><a href="http://starkandwayne.com/articles/2013/04/12/jenkins-builds-from-cli/" target="_blank" rel="noopener">http://starkandwayne.com/articles/2013/04/12/jenkins-builds-from-cli/</a></p>
<p><a href="http://www.scmgalaxy.com/index.php?option=com_k2&amp;view=item&amp;id=890:ways-to-login-jenkins-using-command-line&amp;Itemid=120" target="_blank" rel="noopener">http://www.scmgalaxy.com/index.php?option=com_k2&amp;view=item&amp;id=890:ways-to-login-jenkins-using-command-line&amp;Itemid=120</a></p>
<p><strong>Appendix</strong></p>
<p>1. How to get your_jenkins_API_key?</p>
<ul>
<li>Login to your Jenkins.</li>
<li>Click on the username in the top right.</li>
<li>Click on Configure.</li>
<li>Click on ‘Show API Token’ button.</li>
<li>You got it.</li>
</ul>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/jenkins-command-line-reference-for-login-and-trigger-a-job/">Jenkins Command line Reference for login and trigger a job</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/jenkins-command-line-reference-for-login-and-trigger-a-job/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Know About Jenkins CLI &#124; Jenkins CLI Guide</title>
		<link>https://www.scmgalaxy.com/tutorials/know-about-jenkins-cli/</link>
					<comments>https://www.scmgalaxy.com/tutorials/know-about-jenkins-cli/#respond</comments>
		
		<dc:creator><![CDATA[scmgalaxy K]]></dc:creator>
		<pubDate>Mon, 10 Feb 2014 04:16:10 +0000</pubDate>
				<category><![CDATA[Jenkins]]></category>
		<category><![CDATA[About Jenkins CLI]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Command line]]></category>
		<category><![CDATA[Jenkins CLI]]></category>
		<category><![CDATA[Jenkins CLI Guide]]></category>
		<category><![CDATA[Jenkins CLI Instructions]]></category>
		<category><![CDATA[Jenkins CLI Reference]]></category>
		<category><![CDATA[Jenkins CLI Tutorial]]></category>
		<category><![CDATA[Jenkins Command line]]></category>
		<category><![CDATA[Understand Jenkins CLI]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/2014/02/10/know-about-jenkins-cli/</guid>

					<description><![CDATA[<p>Running CLI java -jar jenkins-cli.jar [-s JENKINS_URL] command [options&#8230;] [arguments&#8230;] Getting help java -jar jenkins-cli.jar -s yourserver.com help [command] How [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/know-about-jenkins-cli/">Know About Jenkins CLI | Jenkins CLI Guide</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img decoding="async" class="alignnone size-full wp-image-3748 aligncenter" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2014/02/jenkins-cli.png" alt="jenkins-cli" width="600" height="400" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2014/02/jenkins-cli.png 600w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2014/02/jenkins-cli-300x200.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></p>
<p><strong>Running CLI</strong><br />
java -jar jenkins-cli.jar [-s JENKINS_URL] command [options&#8230;] [arguments&#8230;]</p>
<p><strong>Getting help</strong><br />
java -jar jenkins-cli.jar -s yourserver.com help [command]</p>
<p><strong>How to download jenkins-cli.jar?</strong><br />
The best place to download the Jenkins CLI jar is from your own Jenkins server. This means you’ll have the matching CLI version. Visit the /cli endpoint, such as http://yourserver.com/cli, and it will give you a link to download the jar (the /jnlpJars/jenkins-cli.jar endpoint). Download that jar.</p>
<p><strong>Running commands against a secure Jenkins (basic auth or ssh keys)</strong></p>
<p>If your Jenkins is secured, and it probably is so that you control who can create jobs, run jobs, view results, then the command above may fail and ask for credentials.<br />
You have two options: provide &#8211;username &amp; &#8211;password options to every command or provide -i option and provide the path to the ssh private key that matches the public key you provided to your user account.<br />
For example:</p>
<p>$ java -jar jenkins-cli.jar -s http://myjenkins help &#8211;username me &#8211;password mypassword<br />
$ java -jar jenkins-cli.jar -s http://myjenkins help -i ~/.ssh/id_rsa</p>
<p><strong>Passing parameters when triggering a job build</strong><br />
To pass those same parameters via the CLI? You use the -p key=value flag for each parameter you want to pass.</p>
<p>So our finished product might look like:</p>
<p>$ java -jar jenkins-cli.jar -s http://myjenkins build &#8216;Deploy XYZ App&#8217; -i ~/.ssh/id_rsa -s -v -p target_env=api.cloudfoundry.com -p branch=master</p>
<p>How to get all commands for Jenkins CLI-<br />
Run &gt; <a href="http://yourserver.com/cli">http://yourserver.com/cli</a></p>
<p><strong>java -jar <a href="http://fmsscm.corp.intuit.net/qbo-qa/jnlpJars/jenkins-cli.jar">jenkins-cli.jar</a> -s http://fmsscm.corp.intuit.net/qbo-qa/ help</strong></p>
<h2>Available Commands</h2>
<ul type="disc">
<li><strong>build</strong>: Builds a job, and optionally waits until its completion.</li>
<li><strong>cancel-quiet-down</strong>: Cancel the effect of the &#8220;quiet-down&#8221; command.</li>
<li><strong>clear-queue</strong>: Clears the build queue</li>
<li><strong>connect-node</strong>: Reconnect to a node</li>
<li><strong>console</strong>: Retrieves console output of a build</li>
<li><strong>copy-job</strong>: Copies a job.</li>
<li><strong>create-job</strong>: Creates a new job by reading stdin as a configuration XML file.</li>
<li><strong>create-node</strong>: Creates a new node by reading stdin as a XML configuration.</li>
<li><strong>delete-builds</strong>: Deletes build record(s).</li>
<li><strong>delete-job</strong>: Deletes a job</li>
<li><strong>delete-node</strong>: Deletes a node</li>
<li><strong>disable-job</strong>: Disables a job</li>
<li><strong>disconnect-node</strong>: Disconnects from a node</li>
<li><strong>enable-job</strong>: Enables a job</li>
<li><strong>get-job</strong>: Dumps the job definition XML to stdout</li>
<li><strong>get-node</strong>: Dumps the node definition XML to stdout</li>
<li><strong>groovy</strong>: Executes the specified Groovy script.</li>
<li><strong>groovysh</strong>: Runs an interactive groovy shell.</li>
<li><strong>help</strong>: Lists all the available commands.</li>
<li><strong>install-plugin</strong>: Installs a plugin either from a file, an URL, or from update center.</li>
<li><strong>install-tool</strong>: Performs automatic tool installation, and print its location to stdout. Can be only called from inside a build.</li>
<li><strong>keep-build</strong>: Mark the build to keep the build forever.</li>
<li><strong>list-changes</strong>: Dumps the changelog for the specified build(s).</li>
<li><strong>list-jobs</strong>: Lists all jobs in a specific view or item group.</li>
<li><strong>list-plugins</strong>: Outputs a list of installed plugins.</li>
<li><strong>login</strong>: Saves the current credential to allow future commands to run without explicit credential information.</li>
<li><strong>logout</strong>: Deletes the credential stored with the login command.</li>
<li><strong>mail</strong>: Reads stdin and sends that out as an e-mail.</li>
<li><strong>offline-node</strong>: Stop using a node for performing builds temporarily, until the next &#8220;online-node&#8221; command.</li>
<li><strong>online-node</strong>: Resume using a node for performing builds, to cancel out the earlier &#8220;offline-node&#8221; command.</li>
<li><strong>quiet-down</strong>: Quiet down Jenkins, in preparation for a restart. Don’t start any builds.</li>
<li><strong>reload-configuration</strong>: Discard all the loaded data in memory and reload everything from file system. Useful when you modified config files directly on disk.</li>
<li><strong>restart</strong>: Restart Jenkins</li>
<li><strong>safe-restart</strong>: Safely restart Jenkins</li>
<li><strong>safe-shutdown</strong>: Puts Jenkins into the quiet mode, wait for existing builds to be completed, and then shut down Jenkins.</li>
<li><strong>session-id</strong>: Outputs the session ID, which changes every time Jenkins restarts</li>
<li><strong>set-build-description</strong>: Sets the description of a build.</li>
<li><strong>set-build-display-name</strong>: Sets the displayName of a build</li>
<li><strong>set-build-parameter</strong>: Update/set the build parameter of the current build in progress</li>
<li><strong>set-build-result</strong>: Sets the result of the current build. Works only if invoked from within a build.</li>
<li><strong>set-external-build-result</strong>: Set external monitor job result.</li>
<li><strong>set-next-build-number</strong>: Set build number to be used for next build.</li>
<li><strong>shutdown</strong>: Immediately shuts down Jenkins server</li>
<li><strong>update-job</strong>: Updates the job definition XML from stdin. The opposite of the get-job command</li>
<li><strong>update-node</strong>: Updates the node definition XML from stdin. The opposite of the get-node command</li>
<li><strong>version</strong>: Outputs the current version.</li>
<li><strong>wait-node-offline</strong>: Wait for a node to become offline</li>
<li><strong>wait-node-online</strong>: Wait for a node to become online</li>
<li><strong>who-am-i</strong>: Reports your credential and permissions</li>
</ul>
<p><strong>Reference –</strong><br />
<a href="https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+CLI">https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+CLI</a><br />
<a href="http://stackoverflow.com/questions/18199355/jenkins-cli-authentication">http://stackoverflow.com/questions/18199355/jenkins-cli-authentication</a><br />
<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></p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/know-about-jenkins-cli/">Know About Jenkins CLI | Jenkins CLI Guide</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/know-about-jenkins-cli/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Understand Jenkins CLI &#124; Jenkins CLI Reference</title>
		<link>https://www.scmgalaxy.com/tutorials/know-about-jenkins-cli-2/</link>
					<comments>https://www.scmgalaxy.com/tutorials/know-about-jenkins-cli-2/#respond</comments>
		
		<dc:creator><![CDATA[scmgalaxy K]]></dc:creator>
		<pubDate>Mon, 10 Feb 2014 04:16:10 +0000</pubDate>
				<category><![CDATA[Jenkins]]></category>
		<category><![CDATA[About Jenkins CLI]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Command line]]></category>
		<category><![CDATA[Jenkins CLI]]></category>
		<category><![CDATA[Jenkins CLI Guide]]></category>
		<category><![CDATA[Jenkins CLI Instructions]]></category>
		<category><![CDATA[Jenkins CLI Reference]]></category>
		<category><![CDATA[Jenkins CLI Tutorial]]></category>
		<category><![CDATA[Jenkins Command line]]></category>
		<category><![CDATA[Understand Jenkins CLI]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/2014/02/10/know-about-jenkins-cli-2/</guid>

					<description><![CDATA[<p>Running CLI java -jar jenkins-cli.jar [-s JENKINS_URL] command [options&#8230;] [arguments&#8230;] Getting help java -jar jenkins-cli.jar -s yourserver.com help [command] How [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/know-about-jenkins-cli-2/">Understand Jenkins CLI | Jenkins CLI Reference</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img loading="lazy" decoding="async" class="aligncenter wp-image-3751 size-full" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2014/02/jenkins-cli-1.png" alt="jenkins-cli" width="600" height="400" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2014/02/jenkins-cli-1.png 600w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2014/02/jenkins-cli-1-300x200.png 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></p>
<p><strong>Running CLI</strong><br />
java -jar jenkins-cli.jar [-s JENKINS_URL] command [options&#8230;] [arguments&#8230;]</p>
<p><strong>Getting help</strong><br />
java -jar jenkins-cli.jar -s yourserver.com help [command]</p>
<p><strong>How to download jenkins-cli.jar?</strong><br />
The best place to download the Jenkins CLI jar is from your own Jenkins server. This means you’ll have the matching CLI version. Visit the /cli endpoint, such as http://yourserver.com/cli, and it will give you a link to download the jar (the /jnlpJars/jenkins-cli.jar endpoint). Download that jar.</p>
<p><strong>Running commands against a secure Jenkins (basic auth or ssh keys)</strong></p>
<p>If your Jenkins is secured, and it probably is so that you control who can create jobs, run jobs, view results, then the command above may fail and ask for credentials.<br />
You have two options: provide &#8211;username &amp; &#8211;password options to every command or provide -i option and provide the path to the ssh private key that matches the public key you provided to your user account.<br />
For example:</p>
<p>$ java -jar jenkins-cli.jar -s http://myjenkins help &#8211;username me &#8211;password mypassword<br />
$ java -jar jenkins-cli.jar -s http://myjenkins help -i ~/.ssh/id_rsa</p>
<p><strong>Passing parameters when triggering a job build</strong><br />
To pass those same parameters via the CLI? You use the -p key=value flag for each parameter you want to pass.</p>
<p>So our finished product might look like:</p>
<p>$ java -jar jenkins-cli.jar -s http://myjenkins build &#8216;Deploy XYZ App&#8217; -i ~/.ssh/id_rsa -s -v -p target_env=api.cloudfoundry.com -p branch=master</p>
<p>How to get all commands for Jenkins CLI-<br />
Run &gt; <a href="http://yourserver.com/cli">http://yourserver.com/cli</a></p>
<p><strong>java -jar <a href="http://fmsscm.corp.intuit.net/qbo-qa/jnlpJars/jenkins-cli.jar">jenkins-cli.jar</a> -s http://fmsscm.corp.intuit.net/qbo-qa/ help</strong></p>
<h2>Available Commands</h2>
<ul type="disc">
<li><strong>build</strong>: Builds a job, and optionally waits until its completion.</li>
<li><strong>cancel-quiet-down</strong>: Cancel the effect of the &#8220;quiet-down&#8221; command.</li>
<li><strong>clear-queue</strong>: Clears the build queue</li>
<li><strong>connect-node</strong>: Reconnect to a node</li>
<li><strong>console</strong>: Retrieves console output of a build</li>
<li><strong>copy-job</strong>: Copies a job.</li>
<li><strong>create-job</strong>: Creates a new job by reading stdin as a configuration XML file.</li>
<li><strong>create-node</strong>: Creates a new node by reading stdin as a XML configuration.</li>
<li><strong>delete-builds</strong>: Deletes build record(s).</li>
<li><strong>delete-job</strong>: Deletes a job</li>
<li><strong>delete-node</strong>: Deletes a node</li>
<li><strong>disable-job</strong>: Disables a job</li>
<li><strong>disconnect-node</strong>: Disconnects from a node</li>
<li><strong>enable-job</strong>: Enables a job</li>
<li><strong>get-job</strong>: Dumps the job definition XML to stdout</li>
<li><strong>get-node</strong>: Dumps the node definition XML to stdout</li>
<li><strong>groovy</strong>: Executes the specified Groovy script.</li>
<li><strong>groovysh</strong>: Runs an interactive groovy shell.</li>
<li><strong>help</strong>: Lists all the available commands.</li>
<li><strong>install-plugin</strong>: Installs a plugin either from a file, an URL, or from update center.</li>
<li><strong>install-tool</strong>: Performs automatic tool installation, and print its location to stdout. Can be only called from inside a build.</li>
<li><strong>keep-build</strong>: Mark the build to keep the build forever.</li>
<li><strong>list-changes</strong>: Dumps the changelog for the specified build(s).</li>
<li><strong>list-jobs</strong>: Lists all jobs in a specific view or item group.</li>
<li><strong>list-plugins</strong>: Outputs a list of installed plugins.</li>
<li><strong>login</strong>: Saves the current credential to allow future commands to run without explicit credential information.</li>
<li><strong>logout</strong>: Deletes the credential stored with the login command.</li>
<li><strong>mail</strong>: Reads stdin and sends that out as an e-mail.</li>
<li><strong>offline-node</strong>: Stop using a node for performing builds temporarily, until the next &#8220;online-node&#8221; command.</li>
<li><strong>online-node</strong>: Resume using a node for performing builds, to cancel out the earlier &#8220;offline-node&#8221; command.</li>
<li><strong>quiet-down</strong>: Quiet down Jenkins, in preparation for a restart. Don’t start any builds.</li>
<li><strong>reload-configuration</strong>: Discard all the loaded data in memory and reload everything from file system. Useful when you modified config files directly on disk.</li>
<li><strong>restart</strong>: Restart Jenkins</li>
<li><strong>safe-restart</strong>: Safely restart Jenkins</li>
<li><strong>safe-shutdown</strong>: Puts Jenkins into the quiet mode, wait for existing builds to be completed, and then shut down Jenkins.</li>
<li><strong>session-id</strong>: Outputs the session ID, which changes every time Jenkins restarts</li>
<li><strong>set-build-description</strong>: Sets the description of a build.</li>
<li><strong>set-build-display-name</strong>: Sets the displayName of a build</li>
<li><strong>set-build-parameter</strong>: Update/set the build parameter of the current build in progress</li>
<li><strong>set-build-result</strong>: Sets the result of the current build. Works only if invoked from within a build.</li>
<li><strong>set-external-build-result</strong>: Set external monitor job result.</li>
<li><strong>set-next-build-number</strong>: Set build number to be used for next build.</li>
<li><strong>shutdown</strong>: Immediately shuts down Jenkins server</li>
<li><strong>update-job</strong>: Updates the job definition XML from stdin. The opposite of the get-job command</li>
<li><strong>update-node</strong>: Updates the node definition XML from stdin. The opposite of the get-node command</li>
<li><strong>version</strong>: Outputs the current version.</li>
<li><strong>wait-node-offline</strong>: Wait for a node to become offline</li>
<li><strong>wait-node-online</strong>: Wait for a node to become online</li>
<li><strong>who-am-i</strong>: Reports your credential and permissions</li>
</ul>
<p><strong>Reference –</strong><br />
<a href="https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+CLI">https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+CLI</a><br />
<a href="http://stackoverflow.com/questions/18199355/jenkins-cli-authentication">http://stackoverflow.com/questions/18199355/jenkins-cli-authentication</a><br />
<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></p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/know-about-jenkins-cli-2/">Understand Jenkins CLI | Jenkins CLI Reference</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/know-about-jenkins-cli-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
