<?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 Tutorials Archives - scmGalaxy</title>
	<atom:link href="https://www.scmgalaxy.com/tutorials/tag/jenkins-tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.scmgalaxy.com/tutorials/tag/jenkins-tutorials/</link>
	<description>A Platform for Software Engineers</description>
	<lastBuildDate>Sat, 27 Feb 2021 09:49:38 +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>How to build when a change is pushed to GitHub in Jenkins?</title>
		<link>https://www.scmgalaxy.com/tutorials/how-to-build-when-a-change-is-pushed-to-github-in-jenkins/</link>
					<comments>https://www.scmgalaxy.com/tutorials/how-to-build-when-a-change-is-pushed-to-github-in-jenkins/#comments</comments>
		
		<dc:creator><![CDATA[scmgalaxy K]]></dc:creator>
		<pubDate>Sun, 15 Jan 2017 02:30:34 +0000</pubDate>
				<category><![CDATA[Git]]></category>
		<category><![CDATA[Jenkins]]></category>
		<category><![CDATA[Build]]></category>
		<category><![CDATA[Change]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[GitHub Plugin]]></category>
		<category><![CDATA[How]]></category>
		<category><![CDATA[Jenkins Guide]]></category>
		<category><![CDATA[Jenkins Tutorials]]></category>
		<category><![CDATA[Push]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/2017/01/15/how-to-build-when-a-change-is-pushed-to-github-in-jenkins/</guid>

					<description><![CDATA[<p>The GitHub plugin for Jenkins is the most basic plugin for integrating Jenkins with GitHub projects. If you are a [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/how-to-build-when-a-change-is-pushed-to-github-in-jenkins/">How to build when a change is pushed to GitHub in Jenkins?</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="alignnone size-full wp-image-2963 aligncenter" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/how-to-build-when-a-change-.png" alt="build-when-a-change-is-pushed-to-github-in-jenkins" width="600" height="400" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/how-to-build-when-a-change-.png 600w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/how-to-build-when-a-change--300x200.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></div>
<div>The GitHub plugin for Jenkins is the most basic plugin for integrating Jenkins with GitHub projects. If you are a GitHub user, this plugin enables you to:</div>
<div></div>
<ul>
<li>Schedule your build</li>
<li>Pull your code and data files from your GitHub repository to your Jenkins machine</li>
<li>Automatically trigger each build on the Jenkins server, after each Commit on your Git repository</li>
</ul>
<div></div>
<div>
<p>This saves you time and lets you incorporate your project into the Continuous Integration (CI) process.</p>
<div><strong>How to Start Working with the GitHub Plugin for Jenkins</strong></div>
<div></div>
<div><strong>Install the Github Jenkins plugin</strong></div>
<div>Go to &#8220;Manage Jenkins&#8221; &#8211;&gt; &#8220;Manage Plugins&#8221; &#8211;&gt; &#8220;Available&#8221; Tab &#8211;&gt; Search for &#8220;GitHub plugin&#8221; and install it.</div>
<div></div>
<div></div>
<div><strong>Configure the plugin with github accounts and keys</strong></div>
<div>Go to &#8220;Manage Jenkins&#8221; &#8211;&gt; &#8220;Configure System&#8221; &#8211;&gt; Locate &#8220;Github&#8221; section and &#8220;Add Github Server&#8221;.</div>
<div><a href="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks2.png"><img decoding="async" class="alignnone wp-image-496 size-full" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks2.png" alt="" width="1301" height="378" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks2.png 1301w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks2-300x87.png 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks2-768x223.png 768w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks2-1024x298.png 1024w" sizes="(max-width: 1301px) 100vw, 1301px" /></a></div>
<div>
<p>API URL &#8211; If you server is github.com, your &#8220;API URL&#8221; would be &#8220;https://api.github.com&#8221; Otherwise if you use GitHub Enterprise, specify its API endpoint here (e.g., <a href="https://ghe.acme.com/api/v3/)">https://ghe.acme.com/api/v3/)</a>.</p>
</div>
<div></div>
<div>Credentials &#8211; You can create your own personal access token in your account GitHub settings.</div>
<div>Token should be registered with scopes: Refer https://github.com/settings/tokens/new.</div>
<div></div>
<div>Add credentials (your Github token), Apply and &#8220;Test Connection&#8221;.<br />
<a href="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks3.png"><img decoding="async" class="alignnone wp-image-497 size-full" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks3.png" alt="" width="1301" height="369" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks3.png 1301w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks3-300x85.png 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks3-768x218.png 768w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks3-1024x290.png 1024w" sizes="(max-width: 1301px) 100vw, 1301px" /></a><br />
<a href="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks4.png"><img loading="lazy" decoding="async" class="alignnone wp-image-498 size-full" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks4.png" alt="" width="1040" height="772" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks4.png 1040w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks4-300x223.png 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks4-768x570.png 768w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks4-1024x760.png 1024w" sizes="auto, (max-width: 1040px) 100vw, 1040px" /></a></div>
<div></div>
<div></div>
<div><strong>Open your Jenkins Project</strong></div>
<div>
<p>a) Check the GitHub project checkbox and set the Project URL to point to your GitHub Repository</p>
<p><a href="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks5.png"><img loading="lazy" decoding="async" class="alignnone wp-image-499 size-full" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks5.png" alt="" width="1301" height="352" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks5.png 1301w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks5-300x81.png 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks5-768x208.png 768w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks5-1024x277.png 1024w" sizes="auto, (max-width: 1301px) 100vw, 1301px" /></a></p>
</div>
<div></div>
<div>b) Under Source Code Management, check Git and set the Repository URL to point to your GitHub Repository<br />
<a href="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks6.png"><img loading="lazy" decoding="async" class="alignnone wp-image-500 size-full" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks6.png" alt="" width="1301" height="559" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks6.png 1301w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks6-300x129.png 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks6-768x330.png 768w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks6-1024x440.png 1024w" sizes="auto, (max-width: 1301px) 100vw, 1301px" /></a></div>
<div></div>
<div>c) Under Build Triggers, check the “Build when a change is pushed to GitHub” checkbox<br />
<a href="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks7.png"><img loading="lazy" decoding="async" class="alignnone wp-image-501 size-full" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks7.png" alt="" width="1301" height="319" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks7.png 1301w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks7-300x74.png 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks7-768x188.png 768w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks7-1024x251.png 1024w" sizes="auto, (max-width: 1301px) 100vw, 1301px" /></a></div>
<div></div>
<div></div>
<div><strong>4. Install the Jenkins (GitHub plugin) and set a webhook to your Jenkins machine</strong></div>
<div>a) From your GitHub repository, go to Settings and then to Integrations &amp; Services</div>
<div>b) Click on Add Service and add ‘Jenkins (GitHub plugin)’</div>
<div>
<p>c) Set the Jenkins hook URL as the URL for your Jenkins machine, and add /github-webhook/</p>
<p><a href="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks8.png"><img loading="lazy" decoding="async" class="alignnone wp-image-502 size-full" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks8.png" alt="" width="1301" height="707" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks8.png 1301w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks8-300x163.png 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks8-768x417.png 768w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks8-1024x556.png 1024w" sizes="auto, (max-width: 1301px) 100vw, 1301px" /></a><br />
<a href="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks9.png"><img loading="lazy" decoding="async" class="alignnone wp-image-503 size-full" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks9.png" alt="" width="1301" height="553" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks9.png 1301w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks9-300x128.png 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks9-768x326.png 768w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks9-1024x435.png 1024w" sizes="auto, (max-width: 1301px) 100vw, 1301px" /></a><br />
<a href="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks10.png"><img loading="lazy" decoding="async" class="alignnone wp-image-504 size-full" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks10.png" alt="" width="1301" height="844" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks10.png 1301w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks10-300x195.png 300w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks10-768x498.png 768w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/01/github-jenkins-integration-hooks10-1024x664.png 1024w" sizes="auto, (max-width: 1301px) 100vw, 1301px" /></a></p>
</div>
<div></div>
<div><strong>Congratulations! Every time you publish your changes to Github, GitHub will trigger your new Jenkins job.</strong></div>
<div></div>
<div></div>
<div><strong>Another Approach noted by suprakash</strong></div>
<div>Actually if you do the web hook settings from Jenkins -&gt; Github plugin configuration (mentioned above), you will still see webhooks get created in github. So , above two approaches basically doing the same thing.</div>
<div></div>
<div>I personally like it to create webhook from Github, because in this way you don&#8217;t have to share or store github user info in jenkins.</div>
<div></div>
<div>Steps : 1. Login into Github (with Admin) 2. Go to the repository you want to hook with jenkins 3. Click on settings tab -&gt; webhooks &amp; services 4. Click on Add Webhook 5. Enter payload url : like : http://:8080/github-webhook/ 6. Select content type as json 7. you are done</div>
<div></div>
<div>
<p>Now you do the changes and commit , you will see jenkins build get trigger automatically. Don&#8217;t forget to do the settings in jenkins jobs to start the build when push code in github.</p>
<p><strong>Reference</strong></p>
<div><a href="https://www.blazemeter.com/blog/how-start-working-github-plugin-jenkins" target="_blank" rel="noopener">https://www.blazemeter.com/blog/how-start-working-github-plugin-jenkins</a></div>
<div><a href="https://wiki.jenkins-ci.org/display/JENKINS/GitHub+Plugin" target="_blank" rel="noopener">https://wiki.jenkins-ci.org/display/JENKINS/GitHub+Plugin</a></div>
<div><a href="http://stackoverflow.com/questions/30576881/jenkins-build-when-a-change-is-pushed-to-github-option-is-not-working" target="_blank" rel="noopener">http://stackoverflow.com/questions/30576881/jenkins-build-when-a-change-is-pushed-to-github-option-is-not-working</a></div>
</div>
</div>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/how-to-build-when-a-change-is-pushed-to-github-in-jenkins/">How to build when a change is pushed to GitHub in Jenkins?</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/how-to-build-when-a-change-is-pushed-to-github-in-jenkins/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<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 loading="lazy" 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="auto, (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>Generate Jenkins Job Configuration Automatically &#124; Jenkins Tutorials</title>
		<link>https://www.scmgalaxy.com/tutorials/generate-jenkins-job-configuration-automatically/</link>
					<comments>https://www.scmgalaxy.com/tutorials/generate-jenkins-job-configuration-automatically/#comments</comments>
		
		<dc:creator><![CDATA[scmgalaxy K]]></dc:creator>
		<pubDate>Wed, 17 Aug 2016 16:41:11 +0000</pubDate>
				<category><![CDATA[Jenkins]]></category>
		<category><![CDATA[Automatically]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Generate]]></category>
		<category><![CDATA[Jenkins Job Builder]]></category>
		<category><![CDATA[Jenkins Job Configuration]]></category>
		<category><![CDATA[Jenkins Tutorials]]></category>
		<category><![CDATA[Job Generator]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/2016/08/17/generate-jenkins-job-configuration-automatically/</guid>

					<description><![CDATA[<p>Generate Jenkins Job Configuration Automatically? Job DSL Plugin The job-dsl-plugin allows the programmatic creation of projects using a DSL. Pushing [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/generate-jenkins-job-configuration-automatically/">Generate Jenkins Job Configuration Automatically | Jenkins Tutorials</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img loading="lazy" decoding="async" class="alignnone size-full wp-image-2944 aligncenter" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2016/08/generate-jenkins-job-config.png" alt="generate-jenkins-job-configuration-automatically" width="600" height="400" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2016/08/generate-jenkins-job-config.png 600w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2016/08/generate-jenkins-job-config-300x200.png 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></div>
<div></div>
<div><strong>Generate Jenkins Job Configuration Automatically?</strong></div>
<div></div>
<div><strong>Job DSL Plugin</strong></div>
<div>The job-dsl-plugin allows the programmatic creation of projects using a DSL. Pushing job creation into a script allows you to automate and standardize your Jenkins installation, unlike anything possible before.</div>
<div>More &#8211;</div>
<div><a href="https://wiki.jenkins-ci.org/display/JENKINS/Job+DSL+Plugin" target="_blank" rel="noopener">https://wiki.jenkins-ci.org/display/JENKINS/Job+DSL+Plugin</a></div>
<div><a href="https://github.com/jenkinsci/job-dsl-plugin/wiki/Tutorial---Using-the-Jenkins-Job-DSL" target="_blank" rel="noopener">https://github.com/jenkinsci/job-dsl-plugin/wiki/Tutorial&#8212;Using-the-Jenkins-Job-DSL</a></div>
<div></div>
<div><strong>Multi-Branch Project Plugin</strong></div>
<div>This plugin adds additional project types that create sub-projects for each branch using a shared configuration.</div>
<div>More &#8211; <a href="https://wiki.jenkins-ci.org/display/JENKINS/Multi-Branch+Project+Plugin" target="_blank" rel="noopener">https://wiki.jenkins-ci.org/display/JENKINS/Multi-Branch+Project+Plugin</a></div>
<div></div>
<div><strong>Job Generator Plugin</strong></div>
<div>This plugin adds a new job type &#8220;Job Generator&#8221; which can generate new projects when executed.</div>
<div>More &#8211; <a href="https://wiki.jenkins-ci.org/display/JENKINS/Job+Generator+Plugin" target="_blank" rel="noopener">https://wiki.jenkins-ci.org/display/JENKINS/Job+Generator+Plugin</a></div>
<div></div>
<div><strong>Jenkins Job Builder</strong></div>
<div>Jenkins Job Builder takes simple descriptions of Jenkins jobs in YAML or JSON format and uses them to configure Jenkins. You can keep your job descriptions in human readable text format in a version control system to make changes and auditing easier. It also has a flexible template system, so creating many similarly configured jobs is easy.</div>
<div></div>
<div>More &#8211;</div>
<div><a href="http://docs.openstack.org/infra/jenkins-job-builder/" target="_blank" rel="noopener">http://docs.openstack.org/infra/jenkins-job-builder/</a></div>
<div><a href="https://www.slalom.com/thinking/automatically-generating-jenkins-jobs" target="_blank" rel="noopener">https://www.slalom.com/thinking/automatically-generating-jenkins-jobs</a></div>
<div></div>
<div><strong>Generating New Jenkins Jobs From Templates and Parameterised Builds</strong></div>
<div>We use Jenkins to run our builds in a continuously. This is great, but you still have to do a fair bit of configuration each time you set up a new job. If you have a fairly static set of builds this isn’t a problem. We found ourselves in a situation where we had to create a lot of very similar builds quite regularly. Creating a new job by hand and manually changing the 10 or so tiny little things in each build is a pain and error prone. So…automate that too!</div>
<div></div>
<div>More</div>
<div><a href="http://www.blackpepper.co.uk/generating-new-jenkins-jobs-from-templates-and-parameterised-builds/" target="_blank" rel="noopener">http://www.blackpepper.co.uk/generating-new-jenkins-jobs-from-templates-and-parameterised-builds/</a></div>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/generate-jenkins-job-configuration-automatically/">Generate Jenkins Job Configuration Automatically | 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/generate-jenkins-job-configuration-automatically/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
