In this tutorial we are going to describe Jenkins installation and configuration with Maven and GitHub. We are going to use a Tomcat Application Server 7. If you don’t have Tomcat installed please get one here. You will need a Java 7+ SDK installed as well
Git binaries installation
At first we need client tool using which git operations like cloning, fetching, pooling can be done. We have chosen git client implementation available at git-scm.com. Download and install it. Important thing is to select Run Git from the Windows Command Prompt option on Adjusting your PATH environment installation screen so that git client executables are added to your PATH variable.
Jenkins installation
Now we are going to install Jenkins. Jenkins is a web application that is being distributed as a WAR archive. Follow this few steps:
- Start Tomcat
- Navigate to jenkins-ci.org and download latest Java Web Archive.
- Copy
jenkins.war
towebapps
directory of your Tomcat installation - Jenkins is available at http://localhost:8080/jenkins
Jenkins GitHub Plugin Installation
In order to build projects that are hosted on a GitHub repository our Jenkins installation has to have GitHub Plugin installed. Follow this steps:
- Navigate to http://localhost:8080/jenkins
- Click
Manage Jenkins
- Click
Manage Plugins
- Click the
Available
tab - In the
Filter
text field enter ‘github’ - Select
GitHub Plugin
and clickDownload now and install after restart
button. Appropriate plugins are being installed - After installation finishes restart Tomcat
Jenkins Maven, Ant and Git configuration
Now we are going to configure Jenkins to use Maven, Ant and a Git client local installations. The steps are:
- Navigate to http://localhost:8080/jenkins
- Click
Manage Jenkins
- Click
Configure System
- In the
JDK
section clickAdd JDK
button, uncheckInstall automatically
checkbox and enterName
andJAVA_HOME
values - Int the
Git
section clickGit Installations...
button and enterName
andPath to Git executable
values
since we have pointed that git client binaries needs to be added to the PATH variable during Git client installation, just enter git client program name – git.exe
- In the
Maven
section clickAdd Maven
button, uncheckInstall automatically
checkbox and enterName
andMAVEN_HOME
- Click
Apply
and thenSave
Testing – Building public repository hosted on GitHub
Now let’s test our configuration. We are going to build one of our project hosted on GitHub. This projects uses maven. It can be found at https://github.com/username/repo.git. Here are the steps:
- Navigate to http://localhost:8080/jenkins
- Click
Click New Job
- Select
Build a free-style software project
option, enterJob name
value and clickOK
- In the
Source Code Management
section selectGit
option - Enter
Repository URL
– for this test let’s usehttps://github.com/username/repo.git
- Click
Advanced
button - Click
Advanced
button – this is the other button that displays after the first click 🙂 - Check
Skip internal tag
checkbox
This will tell Jenkins to clone the repository. If not checked Jenkins would create a separate tag for each build in the repository.
- In the
Build
section selectInvoke top-level Maven targets
- Enter
compile
in theGoals
field - Click
Advanced...
button - Enter
HighScoresServiceClient\pom.xml
in thePOM
field
You need to tell Jenkins where to find pom.xml file when looking from the root of the project.
- Click
Apply
and thenSave
- On the next screen click
Build Now
button - In the
Build History
section a new build has appeared - Move your mouse over it and select
Console Output
item – you can see how project is being cloned and build.
Our Jenkins installation and configuration with Maven, Ant and GitHub works.
The Disqus comment system is loading ...
If the message does not appear, please check your Disqus configuration.