In this post, java application development experts will discuss about Jenkins web based build management tool and its requirement in developing projects. You can read this post and learn how to install Jenkins and make the best use of this management tool.
The necessity of build tool is to integrate the source code properly which are developed by many people for a single project. Each developer works on different modules from the same code base, so frequently the code gets updated.
The build management tool responsibility is to take the latest version of code from the repository and produce the new version of Project. The good features of Jenkins is we can use any build tool and version control. For example, if you are using ANT based build tool, we can configure ANT in Jenkins for your project build process.
If your project is using Maven based build, you can configure Maven for your Project. Similarly you can setup any version control which is available from Jenkins. You can use CVS, SVN, and GIT etc. So, The Jenkins is not live with one particular tool, based on project requirement, we can customize the Jenkins.
I will be explaining following things in this article.
- Jenkins installation steps.
- Creating Project in Jenkins
- Integrating Maven build tool in Jenkins
- Building project using Jenkins.
Jenkins installation steps
Go to following official website for Jenkins
Once you click download button it will prompt following window
Click LTS Release which is a stable one. You will be getting installer file from the download. Double click on the installer and follow the steps to install. You will be seeing the following steps to install it successfully.
After successful installation following folder should create in your windows S.
<Your drive>:\Program Files (x86)\Jenkins
Following path you can see a jenkins.war.
C:\Program Files (x86)\Jenkins
Copy Jenkins war file to your tomcat location of webapp folder. Start the tomcat server by clicking startup.bat file. After starting the server, you can see the Jenkins related logs in server console without error.It means Jenkins deployed in the server successfully.
In the webapp folder you can see the Jenkins folder which is extracted from Jenkins.war.
Use following URL to get Jenkins home page in your local.
This URL gives the home page of Jenkins as in the below screenshot.
Now, we have installed Jenkins in our system and it is running successfully.
Creating Project in Jenkins
Creating Project means you are creating build management Project for your existing Java Project.
Click “create new jobs”. It will show following screen.
Select maven project and enter project name. Here I have entered as “java-spring-maven” then click ok.Next it will ask you to enter project settings for “java-spring-maven”as in the screenshot.
Add some description about the project as in screenshot.
Select source management as none because, I have not used any source management.
Enter pom.xml file path in the Root POM text field and enter the maven Goals as in screenshot.The pom.xml file path should be from your java project folder. In this example I am using java-spring Project which is coming from “F:\Work\example-workspace\java-spring”. Create simple maven based project using eclipse and share that pom.xml file in the field as in above screenshots.
If you want to get email notification while build failure, select the “E-mail Notification” check box and enter valid email as in screenshot.
Once you entered all, click Save button and following screen will appear.
Till now we have integrated maven build tool in Jenkins for a java based maven Project.
We have configured maven build tool in our project and next step is we need to add JDK and maven in Jenkins to run the build.
Click manage Jenkins, you will get following screens.
Click Configuring system
Click Add JDK Button as in screenshot
Once you click “Add JDK” following section will appear.
Deselect install automaticallycheckbox. Once you done that, following section will appear.
Enter your Java version name in JDK Name field and enter your java home in JAVA_HOME field as in the screenshot.
Now we need to give maven information as following. Click Add maven button as in the screenshot.
Once you click, following section will appear.
Unselect “install automatically” check box.You will get following section.
In Above section you need to enter maven name and maven home as in the screenshot below.
We have entered the JDK details and Maven details. Now click save button. Once it saved successfully following screen will appear.
The screen shows the Project details. Click on project name. Once you click it, navigate following screen where it says about the Project information.
We have completed the build setup. Now this is a time to build the application using Jenkins. Click “Build Now” link in side navigation bar as in above screenshot.Once you click “Build Now” link, your project build will start and shows a progress bar as in below screenshot.
If build is completed the progress bar will disappear. Now click #1 link, it will show the build details as in the screenshot.
As per above screenshot we have completed one build successfully. If you want to see the build log click “Console Output” in the side navigation bar. It will show the build log as in the below two screen shot.
Click “Back to Project” from the side navigation bar.
Once you click, you will be navigated to project home page as in below screenshot
If you see highlighted red color box, it shows the build details such as build happened time and how the build went whether success or failure etc. This is showing that our build is success.
If you click “#1”, it will go to following details page.
The ‘Module builds” showing as java-spring. It is our java project name. WhenI set pom.xml path in the project settings, I have pointed out the pom.xml file which belongs to “java-spring” if don’t remember, go back and check the project settings in the document.
When click “Java-spring” link, following screen will appear. This shows generated war file for our deployment which is java-spring-0.0.1-SNAPSHOT.war
Hope this article will help you in making best use of Jenkins tool in java application development. If you did not understand anything, contact professionals and ask your doubts. You can leave your feedback for this post in your comments.Tags: Java, java application development, JDK, Jenkins, Spring, Web Based Application