Friday, 5 July 2019

Jenkins GitHub Integration: Install Git Plugin

You have learned, from previous Guru99 tutorials, what Jenkins is and how to install it onto a Windows system. Assuming you have completed those basic steps, we shall now move on to Plugin management.
Jenkins has outstanding plugin support. There are thousands of third-party application plugins available on their website. To know if Jenkins supports the third-party applications you have in mind, check their plugins directory at https://wiki.jenkins-ci.org/display/JENKINS/Plugins.
In this tutorial, you will learn:
  • Installation of Plugins in Jenkins
  • Install GIT Plugin
  • Integrating Jenkins with GitHub

Installation of Plugins in Jenkins

Jenkins comes with a pretty basic setup, so you will need to install the required plugins to enable respective third-party application support.
GitHub is a web-based repository of code which plays a major role in DevOps. It provides a common platform for multiple developers working on the same code/project to upload and retrieve updated code, thereby facilitating continuous integration.
Jenkins needs to have GitHub plugin installed to be able to pull code from the GitHub repository.
You need not install a GitHub plugin if you have already installed the Git plugin in response to the prompt during the Jenkins' installation setup. But if not, here is how you install GitHub plugins in Jenkins and pull code from a GitHub repository.

Install GIT Plugin

Step 1: Click on the Manage Jenkins button on your Jenkins dashboard:
Step 2: Click on Manage Plugins:
Step 3: In the Plugins Page
  1. Select the GIT Plugin
  2. Click on Install without restart. The plugin will take a few moments to finish downloading depending on your internet connection, and will be installed automatically.
  3. You can also select the option Download now and Install after restart button. In which plugin is installed after restart
  4. You will be shown a "No updates available" message if you already have the Git plugin installed.
Step 4: Once the plugins have been installed, go to Manage Jenkins on your Jenkins dashboard. You will see your plugins listed among the rest.

Integrating Jenkins with GitHub

We shall now discuss the process of integrating GitHub into Jenkins in a Windows system.
Step 1) Create a new job in Jenkins, open the Jenkins dashboard with your Jenkins URL. For example, http://localhost:8080/
Click on create new jobs:
Step 2) Enter the item name, select job type and click OK. We shall create a Freestyle project as an example.
Step 3) Once you click OK, the page will be redirected to its project form. Here you will need to enter the project information:
Step 4) You will see a Git option under Source Code Management if your Git plugin has been installed in Jenkins:
NOTE: If the Git option does not appear, try re-installing the plugins, followed by a restart and a re-login into your Jenkins dashboard. You will now be able to see the Git option as mentioned above.
Step 5) Enter the Git repository URL to pull the code from GitHub.
Step 6) You might get an error message the first time you enter the repository URL. For example:
This happens if you do not have Git installed in your local machine. To install Git in your local machine, go to https://git-scm.com/downloads
Download the appropriate Git file for your Operating System, in this case, Windows, and install it onto your local machine running Jenkins. Complete the onscreen instructions to install GIT.
Step 6) You can execute Git repositories in your Jenkins once Git has been installed on your machine. To check if it has been successfully installed onto your system, open your command prompt, type "Git" and press enter. You should see different options come up for Git:
This means that Git has been installed in your system.
Step 7) Once you have everything in place, try adding the Git URL into Jenkins. You will not see any error messages:
Git is now properly configured on your system.

No comments:

Post a Comment