Jenkins GitHub Integration: How to 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://plugins.jenkins.io/.

Jenkins GitHub Integration

In this Jenkins tutorial, you will learn:

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.

How to Install Git Plugin in Jenkins

Following is a step by step process on how to Install Git plugin in Jenkins:

Step 1: Open your dashboard.
Click on the Manage Jenkins button on your Jenkins dashboard:

Jenkins GitHub Integration

Step 2: Find plugins option.
Click on Manage Plugins:

Jenkins GitHub Integration

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.

Jenkins GitHub Integration

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.

Jenkins GitHub Integration

How to Integrate Jenkins With GitHub

We shall now discuss the process of integrating Jenkins and GitHub 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:

Jenkins GitHub Integration

Step 2) Enter the item name, select job type and click OK. We shall create a Freestyle project as an example.

Jenkins GitHub Integration

Step 3) Once you click OK, the page will be redirected to its project form. Here you will need to enter the project information:

Jenkins GitHub Integration

Step 4) You will see a Git option under Source Code Management if your Git plugin has been installed in Jenkins:

Jenkins GitHub Integration

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.

Jenkins GitHub Integration

Step 6) You might get an error message the first time you enter the repository URL. For example:

Jenkins GitHub Integration

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

Jenkins GitHub Integration

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.

Jenkins GitHub Integration

Step 7) 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:

Jenkins GitHub Integration

This means that Git has been installed in your system.

Note: If you have GIT already installed in your system, just add git.exe path in Global Tool Configuration.

Step 8) Once you have everything in place, try adding the Git URL into Jenkins. You will not see any error messages for Jenkins Git integration:

Jenkins GitHub Integration

Git is now properly configured on your system.

Also Check:- Best Jenkins Alternatives (Open Source & Paid)