Using Git with Jenkins
Jenkins is a continuous integration server and this means it needs to check out source code from a source code repository and build code. Jenkins has excellent support for various source code management systems like CVS, Subversion, etc. Git is fast becoming one of the most popular source code management systems. Jenkins works with Git through the Git plugin.
This blog shows how to use Git with Jenkins. The GitHub plugin should be used if GitHub is the Git server of choice (Using GitHub with Jenkins blog).
We will look at a vanilla set up that is configured to build manually (instead of polling the repo or receiving pushes from the repo).
Stable Release Version
The current stable release is version 1.1.15 and was released in Dec 2011.
Requirement for Plug-in Use
There are not too many requirements for using this plugin:
Jenkins 1.398 or newer
A git repository to talk to ;-)
Step-by-Step Instructions on How to Use the Git Plugin
Go to your Jenkins instance's root page.
If your Jenkins instance has security enabled, login as a user who has the
Overall | Administerpermission.
Manage Jenkinslink on the left-hand side of the screen.
Configure Jenkinslink, give the path to the Git executable on the system or let Jenkins install it automatically.
Go to the the
Availabletab, select the
Git Pluginand click the
Download and Installbutton at the bottom of the page.
Go to your Jenkins instance job.
Configurelink on the left hand side of the screen.
Source Code Managementfield, enter the URL of the Git project which typically looks like:
This sets up your job to checkout all branches on the particular Git repository.
If you have remote branches set up and you would like to build a particular remote branch, add the branch name into the
Branches to build the textbox.
Advanced tab gives a number of options that can be configured on the build. For example: if there is a specific Git user name that should be used, populate the
Config user.name and
Config user.email values.
Tips & Tricks
This plugin can be used to implement a pre-commit feature wherein commits are merged into a stable branch only if builds happen successfully on a development branch. A subsequent blog will outline this advanced usage.
Any Known Issues
There are plans to rewrite the plugin in the future to make the configuration easier.
On Windows, additional steps are required to get the plugin working seamlessly. The steps are covered on the Jenkins Git plugin page.
Senior Director, Product Management
Learn more about managing and scaling Jenkins for the enterprise with this eBook.
Stay up to date
We'll never share your email address and you can opt out at any time, we promise.