{"id":4714,"date":"2019-10-24T07:30:29","date_gmt":"2019-10-24T07:30:29","guid":{"rendered":"https:\/\/cloudkul.com\/blog\/?p=4714"},"modified":"2019-10-24T14:21:00","modified_gmt":"2019-10-24T14:21:00","slug":"ci-cd-github-jenkins","status":"publish","type":"post","link":"https:\/\/cloudkul.com\/blog\/ci-cd-github-jenkins\/","title":{"rendered":"CI\/CD using Github and Jenkins"},"content":{"rendered":"<p>In this blog we will see how to perform CI\/CD using <a href=\"https:\/\/github.com\/\">Github<\/a> and <a href=\"https:\/\/jenkins.io\/doc\/\">Jenkins<\/a>.<\/p>\n<p>One of the basic steps of implementing CI\/CD is integrating your SCM (Source Control Management) tool with your CI tool. This saves you time and keeps your project updated all the time. One of the most popular and valuable SCM tools is GitHub.<\/p>\n<p><em>(Note- If you have your repository on <strong>bitbucket<\/strong> you can refer the following <a href=\"https:\/\/cloudkul.com\/blog\/ci-cd-using-jenkins-and-bitbucket\/\" target=\"_blank\" rel=\"noopener noreferrer\">link.<\/a>)<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>The integration presented in this blog post will teach you to:<\/p>\n<ul>\n<li>Schedule your build<\/li>\n<li>Pull your code and data files from your GitHub repository to your\u00a0<a href=\"https:\/\/jenkins.io\/\">Jenkins<\/a>\u00a0machine<\/li>\n<li>Automatically trigger each build on the Jenkins server, after each Commit on your Git repository.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>For this demo, we will use the following:-<\/p>\n<ol>\n<li><em>Jenkins Server\u00a0<\/em>v2.176.3<\/li>\n<li><em>Ubuntu Server\u00a0<\/em>18.04 LTS<\/li>\n<li>Github private repository<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p>We will launch an EC2 Instance (Ubuntu 18.04LTS) from our AWS console and install apache2 on it by executing the following commands:-<\/p>\n<pre class=\"lang:default decode:true \">sudo apt update\r\nsudo apt install apache2<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Remote SSH Server Configuration:-<\/strong><\/p>\n<p>You need to add your AWS EC2 server under Jenkins.<\/p>\n<p>Log in into your Jenkins server and go to<em>\u00a0Manage Jenkins-&gt; Configure Credentials-&gt; Credentials-&gt; System -&gt; Global Credentials(unrestricted)-&gt; Add Credentials -&gt; and select SSH Username with private key.<\/em><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2019\/10\/SSSSSHHHHHH.png\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-4390 aligncenter\" src=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2019\/10\/SSSSSHHHHHH-300x115.png\" alt=\"\" width=\"715\" height=\"274\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Now we are good to go, let\u2019s configure the Github and Jenkins integration. Let&#8217;s begin with the GitHub side!<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Configuring Github:-<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><em><strong>Step1:-<\/strong>\u00a0<\/em>Go to your Github repository and click on &#8216;Settings&#8217;.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2019\/10\/picture1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-4715\" src=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2019\/10\/picture1-300x61.png\" alt=\"\" width=\"821\" height=\"167\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong><em>Step2:- <\/em><\/strong>Click on Webhooks and then click on \u2018Add webhook\u2019.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2019\/10\/pic2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-4718\" src=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2019\/10\/pic2-300x114.png\" alt=\"\" width=\"784\" height=\"298\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><em><strong>Step3:-<\/strong>\u00a0\u00a0<\/em>Configure the webhook as shown in the figure.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2019\/10\/oie_r4y0jCZ9yfic.png\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-4722 aligncenter\" src=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2019\/10\/oie_r4y0jCZ9yfic-300x270.png\" alt=\"\" width=\"491\" height=\"442\" \/><\/a><\/p>\n<p>(NOTE- your URL should look like this <em><strong>http or<\/strong> <strong>https:\/\/Jenkins_server_IP or domain<\/strong>\/<strong>github-webhhook\/\u00a0<\/strong><\/em>)<\/p>\n<p>&nbsp;<\/p>\n<p>We&#8217;re done with the configuration on GitHub\u2019s side! Now let&#8217;s move on to Jenkins.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Configuring Jenkins:-<\/strong><\/p>\n<p><strong><em>Step1:- <\/em><\/strong>In Jenkins, click on \u2018New Item\u2019 to create a new project.<\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/cdn2.hubspot.net\/hubfs\/208250\/Blog_Images\/jengit6.png\" alt=\"jenkins configuration for github\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong><em>Step2:- <\/em><\/strong>Give your project a name, then choose the \u2018Freestyle project\u2019 and finally click on \u2018OK\u2019.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/cdn2.hubspot.net\/hubfs\/208250\/Blog_Images\/jengit7.png\" width=\"388\" height=\"340\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong><em>Step3:- <\/em><\/strong>Click on the \u2018Source Code Management\u2019 tab<\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/cdn2.hubspot.net\/hubfs\/208250\/Blog_Images\/jrngit8.png\" alt=\"adding your scm to continuous integration\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><em><strong>Step4:-<\/strong> \u00a0<\/em>Paste your GitHub repository URL in the \u2018Repository URL\u2019 field.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2019\/10\/oie_q9zX6WgAzIjv.png\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-4742 aligncenter\" src=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2019\/10\/oie_q9zX6WgAzIjv-300x76.png\" alt=\"\" width=\"710\" height=\"180\" \/><\/a><\/p>\n<p><em>(Note:- If you have a private repo, you need to add your credentials first in Jenkins for which you can refer the following <a href=\"https:\/\/cloudkul.com\/blog\/ci-cd-using-jenkins-and-bitbucket\/\">link<\/a> )<\/em><\/p>\n<p>&nbsp;<\/p>\n<p><strong><em>Step5:- <\/em><\/strong>Click on the \u2018Build Triggers\u2019 tab and then on the \u2018GitHub hook trigger for GITScm polling\u2019. Or, choose the trigger of your choice.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/cdn2.hubspot.net\/hubfs\/208250\/Blog_Images\/jengit10.png\" alt=\"triggering builds in jenkins\" width=\"628\" height=\"286\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><em><strong>Step6:<\/strong>&#8211;<\/em> Under\u00a0<strong>Build\u00a0<\/strong>select\u00a0<em>execute shell script on remote host using ssh<\/em>\u00a0and select your ssh server credentials and under Command write the following:-<\/p>\n<pre class=\"lang:default decode:true\">cd \/var\/www\/html\r\nsudo echo \"CI\/CD Integration is successfull\" &gt; index.html<\/pre>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2019\/10\/oie_K9qn2QZnI2xx.png\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-4740 aligncenter\" src=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2019\/10\/oie_K9qn2QZnI2xx-300x126.png\" alt=\"\" width=\"654\" height=\"275\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Save the job.<\/p>\n<p>Now go to your main repository in Github, and perform any push\/merge operation on it which will result in the following;-<\/p>\n<ul>\n<li>The push\/merge event will activate our webhooks which will trigger our Jenkins job<\/li>\n<li>Our Jenkins job will ssh into our EC2 server and perform the commands specified under the step.<\/li>\n<li>Automatically trigger each build on the Jenkins server, after each Commit on your Git repository.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>On browsing your Apache2 server it should display the following result \u2013<\/p>\n<p><a href=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2019\/10\/oie_kaH68IsTJqI8.png\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-4454 aligncenter\" src=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2019\/10\/oie_kaH68IsTJqI8-300x25.png\" alt=\"\" width=\"1200\" height=\"100\" \/><\/a><\/p>\n<p>Now you have successfully Implemented CI\/CD using Github and Jenkins.<\/p>\n<p>&nbsp;<\/p>\n<p><strong><em>In case of any help or query, please\u00a0<a href=\"https:\/\/cloudkul.com\/contact\/\" target=\"_blank\" rel=\"noopener noreferrer\">contact us<\/a><\/em><em>\u00a0or raise a ticket at<\/em><\/strong><\/p>\n<p><strong><em>\u00a0<a href=\"https:\/\/webkul.uvdesk.com\/en\/customer\/create-ticket\/\">support@webkul.com<\/a>.<\/em><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog we will see how to perform CI\/CD using Github and Jenkins. One <a class=\"text-primary\" title=\"read more\" href=\"https:\/\/cloudkul.com\/blog\/ci-cd-github-jenkins\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":25,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[32,2,87,86],"tags":[65,204,16,206,53,94,39,205,43],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>CI\/CD using Github and Jenkins CI\/CD using Github and Jenkins -<\/title>\n<meta name=\"description\" content=\"In this blog we will explain how to integrate Jenkins with GitHub projects and how CI\/CD can be achieved with their Integration.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cloudkul.com\/blog\/ci-cd-github-jenkins\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CI\/CD using Github and Jenkins CI\/CD using Github and Jenkins -\" \/>\n<meta property=\"og:description\" content=\"In this blog we will explain how to integrate Jenkins with GitHub projects and how CI\/CD can be achieved with their Integration.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudkul.com\/blog\/ci-cd-github-jenkins\/\" \/>\n<meta property=\"og:site_name\" content=\"Cloudkul\" \/>\n<meta property=\"article:published_time\" content=\"2019-10-24T07:30:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-10-24T14:21:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2019\/10\/SSSSSHHHHHH-300x115.png\" \/>\n<meta name=\"author\" content=\"Ayush Singh\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudkul.com\/blog\/ci-cd-github-jenkins\/\",\"url\":\"https:\/\/cloudkul.com\/blog\/ci-cd-github-jenkins\/\",\"name\":\"CI\/CD using Github and Jenkins CI\/CD using Github and Jenkins -\",\"isPartOf\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#website\"},\"datePublished\":\"2019-10-24T07:30:29+00:00\",\"dateModified\":\"2019-10-24T14:21:00+00:00\",\"author\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/bc944fcbc7bf57b5c555d7b088523f1b\"},\"description\":\"In this blog we will explain how to integrate Jenkins with GitHub projects and how CI\/CD can be achieved with their Integration.\",\"breadcrumb\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/ci-cd-github-jenkins\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudkul.com\/blog\/ci-cd-github-jenkins\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudkul.com\/blog\/ci-cd-github-jenkins\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cloudkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CI\/CD using Github and Jenkins\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#website\",\"url\":\"https:\/\/cloudkul.com\/blog\/\",\"name\":\"Cloudkul\",\"description\":\"Host your eCommerce Store on AWS with Optimized Performance\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cloudkul.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/bc944fcbc7bf57b5c555d7b088523f1b\",\"name\":\"Ayush Singh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6c01625f859badb9f845442bb4179cde?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6c01625f859badb9f845442bb4179cde?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"caption\":\"Ayush Singh\"},\"url\":\"https:\/\/cloudkul.com\/blog\/author\/ayushsingh-cloud332\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CI\/CD using Github and Jenkins CI\/CD using Github and Jenkins -","description":"In this blog we will explain how to integrate Jenkins with GitHub projects and how CI\/CD can be achieved with their Integration.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cloudkul.com\/blog\/ci-cd-github-jenkins\/","og_locale":"en_US","og_type":"article","og_title":"CI\/CD using Github and Jenkins CI\/CD using Github and Jenkins -","og_description":"In this blog we will explain how to integrate Jenkins with GitHub projects and how CI\/CD can be achieved with their Integration.","og_url":"https:\/\/cloudkul.com\/blog\/ci-cd-github-jenkins\/","og_site_name":"Cloudkul","article_published_time":"2019-10-24T07:30:29+00:00","article_modified_time":"2019-10-24T14:21:00+00:00","og_image":[{"url":"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2019\/10\/SSSSSHHHHHH-300x115.png"}],"author":"Ayush Singh","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/cloudkul.com\/blog\/ci-cd-github-jenkins\/","url":"https:\/\/cloudkul.com\/blog\/ci-cd-github-jenkins\/","name":"CI\/CD using Github and Jenkins CI\/CD using Github and Jenkins -","isPartOf":{"@id":"https:\/\/cloudkul.com\/blog\/#website"},"datePublished":"2019-10-24T07:30:29+00:00","dateModified":"2019-10-24T14:21:00+00:00","author":{"@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/bc944fcbc7bf57b5c555d7b088523f1b"},"description":"In this blog we will explain how to integrate Jenkins with GitHub projects and how CI\/CD can be achieved with their Integration.","breadcrumb":{"@id":"https:\/\/cloudkul.com\/blog\/ci-cd-github-jenkins\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudkul.com\/blog\/ci-cd-github-jenkins\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/cloudkul.com\/blog\/ci-cd-github-jenkins\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"CI\/CD using Github and Jenkins"}]},{"@type":"WebSite","@id":"https:\/\/cloudkul.com\/blog\/#website","url":"https:\/\/cloudkul.com\/blog\/","name":"Cloudkul","description":"Host your eCommerce Store on AWS with Optimized Performance","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cloudkul.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/bc944fcbc7bf57b5c555d7b088523f1b","name":"Ayush Singh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6c01625f859badb9f845442bb4179cde?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6c01625f859badb9f845442bb4179cde?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","caption":"Ayush Singh"},"url":"https:\/\/cloudkul.com\/blog\/author\/ayushsingh-cloud332\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/4714"}],"collection":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/users\/25"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/comments?post=4714"}],"version-history":[{"count":36,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/4714\/revisions"}],"predecessor-version":[{"id":4761,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/4714\/revisions\/4761"}],"wp:attachment":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/media?parent=4714"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/categories?post=4714"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/tags?post=4714"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}