{"id":739,"date":"2014-07-30T05:34:51","date_gmt":"2014-07-30T09:34:51","guid":{"rendered":"http:\/\/qxf2.com\/blog\/?p=739"},"modified":"2017-06-14T02:00:56","modified_gmt":"2017-06-14T06:00:56","slug":"get-started-with-jenkins","status":"publish","type":"post","link":"https:\/\/qxf2.com\/blog\/get-started-with-jenkins\/","title":{"rendered":"Testers, get started with Jenkins"},"content":{"rendered":"<p><strong>Problem:<\/strong> Many testers do not get a chance to explore Jenkins.<\/p>\n<h3>Why this post?<\/h3>\n<p><a href=\"http:\/\/jenkins-ci.org\/\">Jenkins<\/a> is an open source continuous integration tool written in Java. Jenkins seems to be the popular choice for continuous integration. Due to a variety of reasons, many testers do not get the opportunity to explore and play around with Jenkins. May be your development teams manage Jenkins, may be you joined a testing team after Jenkins was setup and stable, may be Jenkins is hosted on a machine you are not given access too. At <a href=\"http:\/\/www.qxf2.com\">Qxf2 Services<\/a>, we strongly believe in exploring the tools that we use everyday. In this post, we will show you how easy it is to set up Jenkins on your personal machine and learn more about it. Happy learning!<\/p>\n<hr>\n<p>For this tutorial, we take a chess application written in Java, write a unit test and execute the build and tests via a Jenkins job. We are choosing a chess app because Qxf2 loves chess. We have chosen <a href=\"http:\/\/ant.apache.org\/\">Ant<\/a> as our automated build utility. There is nothing special about the choice of Ant here. Jenkins does allow you to integrate various automated build tools with it.<\/p>\n<p><strong>Pro tip:<\/strong> To get the most out of this post, spend some time exploring the different screens Jenkins offers you. <\/p>\n<hr>\n<h3>Getting started with Jenkins to build an app<\/h3>\n<p>1. Download and install Jenkins<br \/>\n2. Install Java and Ant<br \/>\n3. Select an application to build<br \/>\n4. Update the Junit test case<br \/>\n5. Set up the project in Jenkins<br \/>\n6. Start the build<br \/>\n7. Verify the result<\/p>\n<p><strong>STEP 1: <a href=\"http:\/\/jenkins-ci.org\/\">Download and install Jenkins<\/a><\/strong><br \/>\nJenkins provides installers for different operating systems. In companies, it is more common to see Jenkins hosted on a *nix system. Our best guess is that most testers use Windows. Our goal is to help you, the tester, learn about Jenkins. So we are choosing to use Windows in this example. You can download the Windows native package as a zip file. Extract the file and install Jenkins. Since we are installing Jenkins using the Windows installer, we don&#8217;t need to do anything else as the Windows installer automatically runs Jenkins as a Windows service.<\/p>\n<p>You can verify Jenkins is running as a service by launching the Services app from the Windows Start Menu and looking for a running service called &#8220;Jenkins&#8221; among the list of all windows services running on the machine.<\/p>\n<p><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/services_jenkins.gif\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-774\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/services_jenkins-300x123.gif\" alt=\"Windows Service\" width=\"300\" height=\"123\" \/><\/a><\/p>\n<p><strong>NOTE:<\/strong> By default, Jenkins runs at http:\/\/localhost:8080\/. You can change it by editing jenkins.xml, which is located in your installation directory.<\/p>\n<p><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jenkins.jpg\" data-rel=\"lightbox-image-1\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-741\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jenkins-300x176.jpg\" alt=\"Jenkins\" width=\"300\" height=\"176\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jenkins-300x176.jpg 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jenkins-1024x603.jpg 1024w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jenkins.jpg 1177w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><strong>STEP 2: Install Java and Ant<\/strong><br \/>\nJenkins requires Java in order to run, so make sure you have <a href=\"https:\/\/www.java.com\/en\/download\/\">Java <\/a>installed. Since we are building an Java app using Apache Ant you need to download and install <a href=\"http:\/\/ant.apache.org\/bindownload.cgi\">Apache Ant<\/a>. Configure the correct path to your JDK and Apache Ant by clicking on <em>Manage Jenkins<\/em> and then <em>Configure System<\/em> on Jenkins.<\/p>\n<p><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jenkins_java_ant.jpg\" data-rel=\"lightbox-image-2\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-749\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jenkins_java_ant-300x129.jpg\" alt=\"Jenkins configure ant and java path\" width=\"300\" height=\"129\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jenkins_java_ant-300x129.jpg 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jenkins_java_ant-1024x442.jpg 1024w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jenkins_java_ant.jpg 1358w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><strong>STEP 3: Select an application to build <\/strong><br \/>\nWe will take an example of a <a href=\"https:\/\/github.com\/skeeto\/october-chess-engine\">chess app<\/a> posted in github for building through Jenkins. Download the project from github to your local machine. The java chess app has some dependencies, we need to download <a href=\"http:\/\/ant.apache.org\/ivy\/download.cgi\">Apache Ivy<\/a> to manage these dependencies. <a href=\"http:\/\/ant.apache.org\/ivy\/\">Apache Ivy<\/a> is a tool for managing (recording, tracking, resolving and reporting) project dependencies.<\/p>\n<p><strong>STEP 4: Update the test case<\/strong><br \/>\nWe will update the test case to validate that the Title of the Chess app displays as &#8220;October Chess Sample chess Project&#8221;.<\/p>\n<pre lang=\"java\">import com.nullprogram.chess.Chess;\r\nimport org.junit.Test;\r\nimport static org.junit.Assert.assertEquals;\r\n\r\n\r\npublic class BoardTest {\r\n @Test\r\n    public void testGetTitle(){\r\n    \t # Assert that the Application title displays as \"October Chess Sample chess Project\"\r\n    \t assertEquals( \"October Chess Sample chess Project\", Chess.getTitle());\r\n    }\r\n    \r\n}\r\n<\/pre>\n<p>Make sure you have <a href=\"http:\/\/junit.org\/\">Junit.jar<\/a> files included inside your ANT_HOME\/lib directory. Both junit.jar and ant-junit.jar should be present in ANT_HOME\/lib. For more details refer to link<br \/>\n<a href=\"http:\/\/ant.apache.org\/manual\/Tasks\/junit.html\">http:\/\/ant.apache.org\/manual\/Tasks\/junit.html<\/a><\/p>\n<p><strong>STEP 5: Set up the project in Jenkins<\/strong><\/p>\n<ul>\n<li>Go to Jenkins, select &#8220;New Item&#8221;, enter a name for your build and then choose &#8220;Build a free-style software project\u00a0and click &#8220;OK&#8221;.<\/li>\n<li>You can run your project directly from web-based hosting services like Git or Bitbucket. However we will run the project directly from our local machine. Configure the project as &#8220;None&#8221; under &#8220;Source Code Management&#8221;.<\/li>\n<li>Click on &#8220;Add Build step&#8221; and select the ant version.<\/li>\n<li>Click on &#8220;Advanced&#8221; and enter the Build File Path accordingly and click on Save.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jenkins_Build.jpg\" data-rel=\"lightbox-image-3\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-767\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jenkins_Build-300x179.jpg\" alt=\"Jenkins Configure Build\" width=\"300\" height=\"179\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jenkins_Build-300x179.jpg 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jenkins_Build-1024x613.jpg 1024w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jenkins_Build.jpg 1068w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><strong>STEP 6: Start the build<\/strong><br \/>\nGo back to your build page in Jenkins and click on &#8220;Build Now&#8221;. The Build will start and you can view the status. Click on the small icon in the Build History to see the complete Console Output<\/p>\n<p>Note: The initial build will take a longer time since it has to load ivy settings.<\/p>\n<p><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jenkins_Start_Build.png\" data-rel=\"lightbox-image-4\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-777\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jenkins_Start_Build-300x123.png\" alt=\"Jenkins Start Build\" width=\"300\" height=\"123\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jenkins_Start_Build-300x123.png 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jenkins_Start_Build.png 763w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><strong>STEP 7: Verify the result <\/strong><br \/>\nThe Build will succeed however the test case failed as currently the title was displayed as &#8220;October Chess fatal: Not a git repository (or any of the parent directories): .git&#8221;<\/p>\n<p><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jennkins_Console_Testfail.jpg\" data-rel=\"lightbox-image-5\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-768\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jennkins_Console_Testfail-300x157.jpg\" alt=\"Jenkins Test fail\" width=\"300\" height=\"157\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jennkins_Console_Testfail-300x157.jpg 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jennkins_Console_Testfail-1024x537.jpg 1024w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jennkins_Console_Testfail.jpg 1340w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Update the project so that the title displays &#8220;October Chess Sample chess Project&#8221; and re run the Build.<\/p>\n<p>Now both the Test case and Build is successful<\/p>\n<p><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jennkins_Console_TestPass.jpg\" data-rel=\"lightbox-image-6\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-769\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jennkins_Console_TestPass-300x136.jpg\" alt=\"Jenkins Test Pass\" width=\"300\" height=\"136\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jennkins_Console_TestPass-300x136.jpg 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jennkins_Console_TestPass-1024x464.jpg 1024w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/Jennkins_Console_TestPass.jpg 1350w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>You can also check the chess jar File generated and enjoy playing a game of chess!<\/p>\n<p><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/chess_jar.jpg\" data-rel=\"lightbox-image-7\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-756\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/chess_jar-300x87.jpg\" alt=\"Build Output\" width=\"300\" height=\"87\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/chess_jar-300x87.jpg 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2014\/07\/chess_jar.jpg 771w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<hr>\n<h3>Recommended reading<\/h3>\n<p>1. <a href=\"http:\/\/martinfowler.com\/articles\/continuousIntegration.html\">Martin Fowler explains Continuous Integration<\/a>: This Martin Fowler article is still the best starting point to understanding Continuous Integration<\/p>\n<hr>\n<script>(function() {\n\twindow.mc4wp = window.mc4wp || {\n\t\tlisteners: [],\n\t\tforms: {\n\t\t\ton: function(evt, cb) {\n\t\t\t\twindow.mc4wp.listeners.push(\n\t\t\t\t\t{\n\t\t\t\t\t\tevent   : evt,\n\t\t\t\t\t\tcallback: cb\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n})();\n<\/script><!-- Mailchimp for WordPress v4.10.1 - https:\/\/wordpress.org\/plugins\/mailchimp-for-wp\/ --><form id=\"mc4wp-form-1\" class=\"mc4wp-form mc4wp-form-6165 mc4wp-form-theme mc4wp-form-theme-blue\" method=\"post\" data-id=\"6165\" data-name=\"Newsletter\" ><div class=\"mc4wp-form-fields\"><div style=\"border:3px; border-style:dashed;border-color:#56d1e1;padding:1.2em;\">\r\n  <h1 style=\"text-align: center; padding-top: 20px; padding-bottom: 20px; color: #592b1b;\">Subscribe to our weekly Newsletter<\/h1>\r\n  <input style=\"margin: auto;\" type=\"email\" name=\"EMAIL\" placeholder=\"Your email address\" required \/>\r\n  <br>\r\n  <p style=\"text-align: center;\">\r\n    <input style=\"background-color: #890c06 !important; border-color: #890c06;\" type=\"submit\" value=\"Sign up\" \/>\r\n    \r\n  <\/p>\r\n  <p style=\"text-align: center;\">\r\n    <a href=\"http:\/\/mailchi.mp\/c9c7b81ddf13\/the-informed-testers-newsletter-20-oct-2017\"><small>View a sample<\/small><\/a>\r\n  <\/p>\r\n  <br>\r\n<\/div><\/div><label style=\"display: none !important;\">Leave this field empty if you're human: <input type=\"text\" name=\"_mc4wp_honeypot\" value=\"\" tabindex=\"-1\" autocomplete=\"off\" \/><\/label><input type=\"hidden\" name=\"_mc4wp_timestamp\" value=\"1776728453\" \/><input type=\"hidden\" name=\"_mc4wp_form_id\" value=\"6165\" \/><input type=\"hidden\" name=\"_mc4wp_form_element_id\" value=\"mc4wp-form-1\" \/><div class=\"mc4wp-response\"><\/div><\/form><!-- \/ Mailchimp for WordPress Plugin -->\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>Problem: Many testers do not get a chance to explore Jenkins. Why this post? Jenkins is an open source continuous integration tool written in Java. Jenkins seems to be the popular choice for continuous integration. Due to a variety of reasons, many testers do not get the opportunity to explore and play around with Jenkins. May be your development teams [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38,52,53,51,54],"tags":[],"class_list":["post-739","post","type-post","status-publish","format-standard","hentry","category-automation","category-continuous-integration","category-java","category-jenkins","category-junit"],"_links":{"self":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/739","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/comments?post=739"}],"version-history":[{"count":41,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/739\/revisions"}],"predecessor-version":[{"id":6239,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/739\/revisions\/6239"}],"wp:attachment":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/media?parent=739"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/categories?post=739"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/tags?post=739"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}