Continuous Integration
Jenkins is a continuous integration tool.Continuous Integration (CI) is a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.More information on CI can be found https://en.wikipedia.org/wiki/Continuous_integration
Use case:
- Whenever we made some change in our code and push it to repository in GitHub, Jenkins will detect the change and trigger the build process using Maven
- Create a Jenkin job to build a project using maven for a repository in Github and run it on demand
Prerequisite:
Before we can start working on integrating Jenkins with Maven and Github we need to complete below steps1. Download Tomcat
Apache Tomcat, often referred to as Tomcat, is an open-source web server developed by the Apache Software Foundation (ASF). It implements specification for Java Servlet. JSP, Java EL and websocket.Download tomcat from https://tomcat.apache.org/download-70.cgi
More information on Tomact can be found here http://tomcat.apache.org/
2. Download Jenkins
This is an open source continuous integration tool written in Java. This is a server based system running in a servlet container such as Apache Tomcat.More information on Jenkins can be found here https://jenkins-ci.org/
3. Create Repository in Github
This is a source code management system for software development. You should create a repository and push your code in repositoryAdditional information on how to create repository can be found here
https://help.github.com/articles/creating-a-new-repository/
4. Download Maven
This is a build automation tool used primarily for Java projects. More information can be found here https://maven.apache.org/Quick Steps:
1. Once Tomcat and jenkins.war are downloaded, Go to tomcat installation directory and to webapps folder.
2. Copy Jenkins.war in webapps directory ( ..\apache-tomcat-7.0.64\webapps)
3. Start the tomcat server.
D:\apache-tomcat-7.0.64\bin>startup.bat
4. Once server is started, open a browser and go to URL.
http://localhost:8080/jenkins/
Note: Port number in above URL can be different depending on tomcat configuration file server.xml which can be found in the location ...apache-tomcat-7.0.64\conf
5. Once Jenkins homepage is opened go to Manage jenkins and then to Configure System
6. In configuration page you configure java, git and maven as show below. There are lots of other advance configuration that can be done from here as well. We did only the minimum required to configure Jenkins with GitHub and Maven
6.1 Java
6.2 Git
6.2.1 Add path to Git in the PATH environment variable as shown
6.2.2 Configure Git in Jenkins as shown below
6.3 Maven: Configure Maven as show below
7. Apply and save the changes in configuration page. Ensure that there is no error while you configure java, git and maven.
Tips: You can go back to configuration page to check if there is any error in above configuration.
8. Go to Manage Jenkins and then to Manage Plugins
9. In Manage Plugin page we have to ensure that we have all the plugin necessary for Git and Maven. Following are the Maven and Git plugin respectively.
Note: If plugins are not present in Installed tab, go to Available tab check for the plugin and download/install the same.
Configuration is now all set.
Create a basic Jenkins job
1. From the Jenkins homepage go to ‘New Item’. In new item page give a name to the job and select ‘Freesytle project’ as shown below. Hit OK.
2. Start configuring the job.
3. Project Name will be automatically populated.
4. You can give a description to the job.
5. In Source Code Management Configure following
5.1 Git
5.2 Repository/Credentials (For the first time use click on ‘Add’ to add new credential.)
5.3 The Git repository branch you would like to work with. By default it is the master
6. In Build configuration configuration click on ‘Add build step’ and select ‘Invoke Maven 3’
Configure Maven as shown below.
7. Build trigger can be configured to trigger the job. For our use case we have selected to poll github every minute. If there is any change in repository job will be triggered within 1 minute.
8. We can also trigger the Jenkins job manually with the option' build now' in the job home page.
The post is a quick steps to configure Jenkins with Maven and GitHub.
For more advance Jenkins configuration you can go to
1. https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project
2.https://wiki.jenkins-ci.org/display/JENKINS/Step+by+step+guide+to+set+up+master+and+slave+machines
3.http://michal.karzynski.pl/blog/2014/04/19/continuous-integration-server-for-django-using-jenkins/













No comments:
Post a Comment