Overview
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
Installation
Go to your Jenkins instance's root page.
If your Jenkins instance has security enabled, login as a user who has the
Overall | Administer
permission.Select the
Manage Jenkins
link on the left-hand side of the screen.Select the
Configure Jenkins
link, give the path to the Git executable on the system or let Jenkins install it automatically.Go to the the
Manage Plugins
link.On the
Available
tab, select theGit Plugin
and click theDownload and Install
button at the bottom of the page.
Configuration
Go to your Jenkins instance job.
Select the
Configure
link on the left hand side of the screen.In the
Source Code Management
field, enter the URL of the Git project which typically looks like:
ssh://git@git.cloudbees.com/project.git.
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.
The 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.
Relevant Documentation
Thanks,
Harpreet Singh
Senior Director, Product Management
CloudBees
cloudbees.com
Learn more about managing and scaling Jenkins for the enterprise with this eBook.