{"id":626,"date":"2017-12-27T23:22:56","date_gmt":"2017-12-27T15:22:56","guid":{"rendered":"https:\/\/www.techcoil.com\/blog\/?p=626"},"modified":"2018-09-05T10:58:41","modified_gmt":"2018-09-05T02:58:41","slug":"how-i-setup-jenkins-on-my-raspberry-pi-3-with-raspbian-stretch-lite","status":"publish","type":"post","link":"https:\/\/www.techcoil.com\/blog\/how-i-setup-jenkins-on-my-raspberry-pi-3-with-raspbian-stretch-lite\/","title":{"rendered":"How I setup Jenkins on my Raspberry Pi 3 with Raspbian Stretch Lite"},"content":{"rendered":"<p><a href=\"https:\/\/jenkins.io\/\" rel=\"noopener\" target=\"_blank\">Jenkins<\/a> is a renowned open source automation server that can help offload programmers from performing repetitive tasks like:<\/p>\n<ul>\n<li>running unit tests to make sure new code does not break existing codes.<\/li>\n<li>compiling and packaging the binaries from codes and dependencies.<\/li>\n<li>deploying new binaries to testing servers.<\/li>\n<li>checking whether production server is up and running.<\/li>\n<li>and etc.<\/li>\n<\/ul>\n<p>If you have a Raspberry Pi 3 and you want to automate some of the tasks for your side projects, you may want to consider setting up Jenkins on your Raspberry Pi 3 with Raspbian Stretch Lite as the operating system. <\/p>\n<p>This post documents how I setup Jenkins on my Raspberry Pi 3 with Raspbian Stretch Lite.<\/p>\n<h2>My hardware list for this setup<\/h2>\n<p>I used the following hardware for my Jenkins server:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.amazon.com\/gp\/product\/B01CD5VC92\/ref=as_li_tl?ie=UTF8&tag=clivsperswebs-20&camp=1789&creative=9325&linkCode=as2&creativeASIN=B01CD5VC92&linkId=5e9e3f9b7a5f3d871801a9cb350be78c\" target=\"_blank\">Raspberry PI 3 Model B A1.2GHz 64-bit quad-core ARMv8 CPU, 1GB RAM<\/a><\/li>\n<li><a href=\"https:\/\/www.amazon.com\/gp\/product\/B01CK3XTIE\/ref=as_li_tl?ie=UTF8&tag=clivsperswebs-20&camp=1789&creative=9325&linkCode=as2&creativeASIN=B01CK3XTIE&linkId=8a8d9800f926527bc41890fbf50455cd\" target=\"_blank\">Official Raspberry Pi 3 Case - Red\/White<\/a><\/li>\n<li><a href=\"https:\/\/www.amazon.com\/gp\/product\/B0166RR85U\/ref=as_li_tl?ie=UTF8&tag=clivsperswebs-20&camp=1789&creative=9325&linkCode=as2&creativeASIN=B0166RR85U&linkId=d9bafc959cf145db92885a2a5d247739\" target=\"_blank\">Kingston Digital 32GB microSDHC Class 10 UHS-I 45R Flash Card (SDC10G2\/32GBSP)<\/a><\/li>\n<li>Unused <a href=\"https:\/\/www.amazon.com\/s\/ref=as_li_ss_tl?url=search-alias=aps&field-keywords=USB+charger&linkCode=ll2&tag=clivsperswebs-20&linkId=3f0cc3128101afcfe7ccdc4d9c856568\" rel=\"noopener\" target=\"_blank\">USB charger<\/a><\/li>\n<li><a href=\"https:\/\/www.amazon.com\/gp\/product\/B00N2VISLW\/ref=as_li_tl?ie=UTF8&tag=clivsperswebs-20&camp=1789&creative=9325&linkCode=as2&creativeASIN=B00N2VISLW&linkId=132403a064ff21634835c1deee4bc983\" target=\"_blank\">AmazonBasics RJ45 Cat-6 Ethernet Patch Cable - 3 Feet (0.9 Meters)<\/a><\/li>\n<\/ul>\n<h2>Setting up Raspbian Stretch Lite with SSH server enabled on my microSD card<\/h2>\n<p>Once I had gathered all the necessary hardware, I proceeded to <a href=\"https:\/\/www.techcoil.com\/blog\/how-to-setup-raspbian-stretch-lite-with-ssh-server-enabled-on-your-microsd-card\/\" rel=\"noopener\" target=\"_blank\">setup Raspbian Stretch Lite with SSH server enabled on my microSD card<\/a>. Doing so allowed me to SSH into my Raspbian Stretch Lite to perform further configurations in this post. <\/p>\n<h2>Assembling the hardware for the Raspberry Pi LEMP Server<\/h2>\n<p>Next, I removed my microSD card from my SD card reader and inserted it to the microSD card slot on the Raspberry Pi 3 board. After that, I went ahead to <a href=\"\/blog\/how-to-assemble-the-raspberry-pi-3-board-with-the-raspberry-pi-official-case\/\" target=\"_blank\">assemble the Raspberry Pi 3 board to the Official Raspberry Pi case<\/a>.<\/p>\n<h2>Starting the Raspbian Stretch Lite operating system<\/h2>\n<p>With the assembly of my Raspberry Pi 3 board and Official Raspberry Pi case, I connected one end of the RJ45 cable to the RJ45 port on my Raspberry Pi 3 board and the other end of the cable to one of the switch port of <a href=\"https:\/\/www.amazon.com\/Linksys-AC1900-Wireless-Router-EA7500\/dp\/B019WAQMVY\/ref=as_li_ss_tl?ie=UTF8&qid=1503756300&sr=8-2&keywords=linksys+ac1900+max+stream&linkCode=ll1&tag=clivsperswebs-20&linkId=d4ff7c0f2b2478e935b444a7bd6a2511\" target=\"_blank\">my home router<\/a>. After that, I connected my micro USB cable and supply power to my Raspberry Pi 3 board.<\/p>\n<h2>Changing default password, Locale and Timezone of my Raspbian Stretch Lite<\/h2>\n<p>There are a few configurations that we should perform on the first run of Raspbian Stretch Lite. Therefore, I proceeded on to <a href=\"https:\/\/www.techcoil.com\/blog\/set-of-configurations-to-perform-on-the-first-run-of-your-raspbian-stretch-lite\/\" rel=\"noopener\" target=\"_blank\">change the default password, Locale and Timezone of Raspbian Stretch Lite<\/a>.  <\/p>\n<h2>Preventing Hash Sum mismatch errors<\/h2>\n<p>By default, this installation of Raspbian Stretch Lite will attempt to download packages from a mirror that is nearest to my location. However, the download processes for some of the packages threw <strong>Hash Sum mismatch<\/strong> errors. To prevent such errors from occurring, I configured apt-get to always download packages from archive.raspbian.org. To do so, I changed the contents of the <code>\/etc\/apt\/sources.list<\/code> file to look like the following:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n#deb http:\/\/mirrordirector.raspbian.org\/raspbian\/ stretch main contrib non-free rpi\n# Uncomment line below then 'apt-get update' to enable 'apt-get source'\n#deb-src http:\/\/archive.raspbian.org\/raspbian\/ stretch main contrib non-free rpi\n\ndeb http:\/\/archive.raspbian.org\/raspbian\/ stretch main contrib non-free rpi\n<\/pre>\n<h2>Installing Java on my Raspbian Stretch Lite<\/h2>\n<p>Jenkins is written in Java. As such, I will need to get Java installed on my Raspbian Stretch Lite. To install <a href=\"https:\/\/www.techcoil.com\/blog\/how-i-make-my-java-programs-run-faster-on-my-raspberry-pi-3\/\" rel=\"noopener\" target=\"_blank\">the faster Java version<\/a> on Raspbian Stretch Lite, I entered the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo apt-get install oracle-java8-jdk -y\n<\/pre>\n<p>After the command had completed, I ran the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\njava -version\n<\/pre>\n<p>and got the following output as an indication that Java 8 was installed successfully:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nJava(TM) SE Runtime Environment (build 1.8.0_65-b17)\nJava HotSpot(TM) Client VM (build 25.65-b01, mixed mode)\n<\/pre>\n<h2>Installing Jenkins<\/h2>\n<p>Once I had installed Java on my Raspbian Stretch Lite, I continued on to install Jenkins. To do so, I entered the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nwget -q -O - https:\/\/jenkins-ci.org\/debian\/jenkins-ci.org.key | sudo apt-key add -\nsudo sh -c 'echo deb http:\/\/pkg.jenkins-ci.org\/debian binary\/ &gt; \/etc\/apt\/sources.list.d\/jenkins.list'\nsudo apt-get update\nsudo apt-get install jenkins -y\n<\/pre>\n<p>Once the command had completed, I ran the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsystemctl status jenkins.service\n<\/pre>\n<p>and got the following output as an indication that Jenkins was installed successfully:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\u25cf jenkins.service - LSB: Start Jenkins at boot time\n   Loaded: loaded (\/etc\/init.d\/jenkins; generated; vendor preset: enabled)\n   Active: active (exited) since Wed 2017-12-27 22:14:45 +08; 4min 40s ago\n     Docs: man:systemd-sysv-generator(8)\n\nDec 27 22:14:43 raspberrypi systemd&#x5B;1]: Starting LSB: Start Jenkins at boot time...\nDec 27 22:14:43 raspberrypi jenkins&#x5B;1670]: Correct java version found\nDec 27 22:14:43 raspberrypi su&#x5B;1700]: Successful su for jenkins by root\nDec 27 22:14:43 raspberrypi su&#x5B;1700]: + ??? root:jenkins\nDec 27 22:14:43 raspberrypi su&#x5B;1700]: pam_unix(su:session): session opened for user jenkins by (uid=0)\nDec 27 22:14:45 raspberrypi jenkins&#x5B;1670]: Starting Jenkins Automation Server: jenkins.\nDec 27 22:14:45 raspberrypi systemd&#x5B;1]: Started LSB: Start Jenkins at boot time.\n<\/pre>\n<p>Once Jenkins was installed, I could access it with my browser via <strong><code>http:\/\/192.168.1.109:8080<\/code><\/strong>. <\/p>\n<h2>Unlocking Jenkins<\/h2>\n<p>The Jenkins that I had installed showed the following screen when I accessed it for the first time:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/jenkins-20171227-first-run-unlock-jenkins-screen.gif\" alt=\"Jenkins 20171227 first run unlock Jenkins screen\"\/><\/p>\n<p>Following the instructions, I got the initial admin password for Jenkins on my terminal screen with the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo cat \/var\/lib\/jenkins\/secrets\/initialAdminPassword\n<\/pre>\n<p>and supplied it to the text field on the <strong>Unlock Jenkins<\/strong> page. I then clicked on the <strong>Continue<\/strong> button to proceed with the initial configurations of Jenkins.<\/p>\n<h2>Going through Jenkins initial configurations<\/h2>\n<p>Once Jenkins is unlocked, I then followed through some initial configurations screens.<\/p>\n<p>Firstly, I clicked on <strong>Skip Plugin Installations<\/strong> button at the screen that notified that my Jenkins instance was offline.<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/jenkins-20171227-offline-notification-screen.gif\" alt=\"Jenkins 20171227 offline notification screen\" \/><\/p>\n<p>In the <strong>Create First Admin User<\/strong> page, I supplied the first admin user credentials and clicked on the <strong>Save and Finish<\/strong> button.<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/jenkins-20171227-create-first-admin-user-screen.gif\" alt=\"Jenkins 20171227 create first admin user screen\" \/><\/p>\n<p>After the first admin user was created, I clicked on the <strong>Start Using Jenkins<\/strong> button to start using Jenkins.<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/jenkins-20171227-jenkins-is-ready-screen.gif\" alt=\"Jenkins 20171227 Jenkins is ready screen\" \/><\/p>\n<p>That marked the end of the initial configurations for Jenkins. With that, I Jenkins showed me the home screen to create new jobs.<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/jenkins-20171227-welcome-screen.gif\" alt=\"Jenkins 20171227 welcome screen\"\/><\/p>\n<h2>Buying the hardware to build your Jenkins server on a Raspberry Pi 3<\/h2>\n<p>If you do not have the Raspberry Pi 3 hardware mentioned in this post yet, you may want to purchase them from Amazon. Simply click on the button below to add the Raspberry Pi 3 hardware to your cart. You may remove anything that you already have or replace some of the hardware with other hardware.<\/p>\n<p><center><\/p>\n<form action=\"https:\/\/www.amazon.com\/gp\/aws\/cart\/add.html\" method=\"GET\" target=\"_blank\"><input name=\"AssociateTag\" type=\"hidden\" value=\"clivsperswebs-20\"\/><input name=\"SubscriptionId\" type=\"hidden\" value=\"[AKIAIMND5UBCQU2HRSUA]\"\/><input name=\"ASIN.1\" type=\"hidden\" value=\"B01CD5VC92\"\/><input name=\"Quantity.1\" type=\"hidden\" value=\"1\"\/><input name=\"ASIN.2\" type=\"hidden\" value=\"B01CCPKCSK\"\/><input name=\"Quantity.2\" type=\"hidden\" value=\"1\"\/><input name=\"ASIN.3\" type=\"hidden\" value=\"B0166RR85U\"\/><input name=\"Quantity.3\" type=\"hidden\" value=\"1\"\/><input name=\"ASIN.4\" type=\"hidden\" value=\"B00N2VISLW\"\/><input name=\"Quantity.4\" type=\"hidden\" value=\"1\"\/><br \/>\n<input alt=\"Buy from Amazon.com\" name=\"add\" type=\"image\" src=\"https:\/\/images-na.ssl-images-amazon.com\/images\/G\/01\/associates\/remote-buy-box\/buy4.gif\" value=\"Buy from Amazon.com\"><\/form>\n<p><\/center><\/p>\n\n      <ul id=\"social-sharing-buttons-list\">\n        <li class=\"facebook\">\n          <a href=\"https:\/\/www.facebook.com\/sharer\/sharer.php?u=https%3A%2F%2Fwp.me%2Fp245TQ-a6\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n            <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Facebook.png\" alt=\"Facebook icon\"> Share\n          <\/a>\n        <\/li>\n        <li class=\"twitter\">\n          <a href=\"https:\/\/twitter.com\/intent\/tweet?text=&url=https%3A%2F%2Fwp.me%2Fp245TQ-a6&via=Techcoil_com\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Twitter.png\" alt=\"Twitter icon\"> Tweet\n          <\/a>\n        <\/li>\n        <li class=\"linkedin\">\n          <a href=\"https:\/\/www.linkedin.com\/shareArticle?mini=1&title=&url=https%3A%2F%2Fwp.me%2Fp245TQ-a6&source=https:\/\/www.techcoil.com\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/linkedin.png\" alt=\"Linkedin icon\"> Share\n          <\/a>\n        <\/li>\n        <li class=\"pinterest\">\n          <a href=\"https:\/\/pinterest.com\/pin\/create\/button\/?url=https%3A%2F%2Fwww.techcoil.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F626&description=\" class=\"pin-it-button\" target=\"_blank\" role=\"button\" rel=\"nofollow\" count-layout=\"horizontal\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Pinterest.png\" alt=\"Pinterest icon\"> Save\n          <\/a>\n        <\/li>\n      <\/ul>\n    ","protected":false},"excerpt":{"rendered":"<p><a href=\"https:\/\/jenkins.io\/\" rel=\"noopener\" target=\"_blank\">Jenkins<\/a> is a renowned open source automation server that can help offload programmers from performing repetitive tasks like:<\/p>\n<ul>\n<li>running unit tests to make sure new code does not break existing codes.<\/li>\n<li>compiling and packaging the binaries from codes and dependencies.<\/li>\n<li>deploying new binaries to testing servers.<\/li>\n<li>checking whether production server is up and running.<\/li>\n<li>and etc.<\/li>\n<\/ul>\n<p>If you have a Raspberry Pi 3 and you want to automate some of the tasks for your side projects, you may want to consider setting up Jenkins on your Raspberry Pi 3 with Raspbian Stretch Lite as the operating system. <\/p>\n<p>This post documents how I setup Jenkins on my Raspberry Pi 3 with Raspbian Stretch Lite.<\/p>\n","protected":false},"author":1,"featured_media":898,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"footnotes":""},"categories":[4],"tags":[473,6,244,314,240,308,412,445,423,195],"jetpack_featured_media_url":"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/jenkins-20171227-welcome-screen.gif","jetpack_shortlink":"https:\/\/wp.me\/p245TQ-a6","jetpack-related-posts":[],"jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts\/626"}],"collection":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/comments?post=626"}],"version-history":[{"count":0,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts\/626\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/media\/898"}],"wp:attachment":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/media?parent=626"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/categories?post=626"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/tags?post=626"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}