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
- Jenkins 1.398 or newer
- A git repository to talk to ;-)
Step-by-Step Instructions on How to Use the GitHub Plugin
- 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 the Git Plugin and click the Download and Install button at the bottom of the page.
- 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://email@example.com/project.git.
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.
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.
How to Use it on DEV@cloud/RUN@cloud
If you are using the CloudBees Platform as a Service (PaaS), the plugin is identical to configure on DEV@cloud except you do not need to install Git.
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.
Want to learn the latest in Jenkins? Subscribe to the Jenkins newsletter, Continuous Information. This monthly newsletter contains all of the latest interesting and useful happenings in the Jenkins community, sent directly to your inbox.