What is Jenkins
Jenkins is a powerful application that allows continuous integration and continuous delivery of projects, regardless of the platform you are working on. It is a free source that can handle any kind of build or continuous integration. You can integrate Jenkins with a number of testing and deployment technologies.
How Jenkins work?
Below point explains the work flow of jenkins:
1) Developers commit and push their code
2) Jenkins will pick up the changed source code and trigger a build and run the test cases.
3) The build output will be available in the jenkins dashboard. Automatic notification can be sent back to the developer.
Getting Started with Jenkins:
1) System Requirements
- Jenkins requires Java7 or above to function. Java8 is recommended.
- Jenkins requires a fair amount of memory to operate well.
Setup JAVA_HOME in .bashrc :
2) Download Jenkins
Open the command prompt. From the command prompt, browse to the directory where the jenkins.war file is present. Run the following command:
java -jar jenkins.war
After the command is run, various tasks will run, one of which is the extraction of the war file which is done by an embedded webserver called winstone. Once the processing is complete without major errors, the following line will come in the output of the command prompt.
INFO: Jenkins is fully up and running
Note: Jenkins by default use port 8080. To run it on different port :
java -jar jenkins.war –httpPort=9090
It will run jenkins. at port 9090
Once Jenkins is up and running, one can access Jenkins from the link −http://localhost:8080 (default)
This link will bring up the Jenkins dashboard.
Setting up Jenkins with Tomcat
The following prerequisites must be met for Jenkins Tomcat setup.
Step 1: Verify Java Installation
To verify Java installation, open the console and execute the following java command.
It should display output as per the version like :
java version “1.8.0_92”
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
Step2: Verify whether JAVA_HOME variable is set
It can be done using command, where output must specify the path of Java Home:
If the path is not set, then set JAVA_HOME environment variable to point to the base directory location where Java is installed on your machine. Eg.
Step 3: Download Tomcat
1) From official website of tomcat: https://tomcat.apache.org/download-70.cgi, download tar.gz file From “Binary Distributions” under Core bullet.
2) Then extract the contents of the downloaded tar.gz file.
Step 4: Jenkins and Tomcat Setup
Copy the Jenkis.war file which was downloaded from the previous section and copy it to the webapps folder in the tomcat folder.
Now open the command prompt. From the command prompt, browse to the directory where the tomcat folder is located. Browse to the bin directory in this folder and run the below command
Once the processing is complete without major errors, the following line will come in the output of the command prompt.
INFO: Server startup in 1310 ms
Open the browser and go to the link −http://localhost:8080/jenkins. Jenkins will be up and running on tomcat.
NOTE : If the port is already in use, it can be changed in file server.xml inside conf folder of apache-tomcat.
Following lines define the port number in server.xml:
<Connector port=”8080″ protocol=”HTTP/1.1″
Here 8080 can be replaced with any other unused port (say 9090)
Now to open the browser and go to the link −http://localhost:9090/jenkins. Jenkins will be up and running on tomcat.
Following are the steps to be followed:
1) In your Jenkins Dashboard (Home screen), click the Manage Jenkins option on the left hand side.
2) In the next screen, click the ‘Manage Plugins’ option.
3) In the next screen, click the Available tab. This tab will give a list of plugins which are available for downloading. In the ‘Filter’ tab type ‘Git plugin’.
4) The list will then be filtered. Check the Git Plugin option and click on the button ‘Install without restart’.
5) The installation will then begin and the screen will be refreshed to show the status of the download.
6) Once all installations are complete, restart Jenkins by issuing the following command in the browser.
7) After Jenkins is restarted, Git will be available as an option whilst configuring jobs. To verify, click on New Item in the menu options for Jenkins. Then enter a name for a job, in the following case, the name entered is ‘Demo’. Select ‘Freestyle project’ as the item type. Click the Ok button.
8) In the next screen, if you browse to the Source code Management section, you will now see ‘Git’ as an option.
NOTE: In case Git is already setup then it will be available in Installed tabs in “Manage Plugins”
1) From official homepage of maven ://maven.apache.org/download.cgi download the link to the Binary.zip file under “Files Section”
2) Once the file is downloaded, extract the files at your local directory say /opt/local-maven/apache-maven-3.3.9
1) In the Jenkins dashboard (Home screen), click Manage Jenkins from the left-hand side menu.
2) Click on ‘Configure System’ from the right hand side.
3) In the Configure system screen, scroll down till you see the Maven section and then click on the ‘Add Maven’ button.
4) Uncheck the ‘Install automatically’ option.
5) Add any name for the setting and the location of the MAVEN_HOME. For example:
6) Then, click on the ‘Save’ button at the end of the screen.
Note: If you are using 2.x version of jenkins, you can find maven at
Jenkins(Home) -> Manage Jenkins -> Global Tool Configuration
You can now create a job with the ‘Maven project’ option. In the Jenkins dashboard, click the New Item option.
If you still cannot see “Maven Project” in “New” window then perform the given steps:
1) Click Manage Jenkins
2) Click Manage Plugins
3) Search for “Maven Integration plugin” using filter and click on “Install without Restart”
4) Once the download is complete, restart jenkins by hitting URL :
Now you are ready to build and test your maven projects.