In this post, java application development experts will discuss 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 the code from the repository and produce the new version of Project. The good features of Jenkins are 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 set up 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 the project requirement, we can customize the Jenkins.
I will be explaining the 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 the following window
Click the LTS release which is stable you will get the installer file from the download. Double click on the installer and follow the steps to install you will see 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 web app folder. Start the tomcat server by clicking the startup.bat file. After starting the server, you can see the Jenkins related logs in the 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 the 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 a building management Project for your existing Java Project.
Click “create new jobs”. It will show the following screen.
Select the Maven project and enter the 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 of the project as in the 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 the 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 the above screenshots.
If you want to get email notification while build failure, select the “E-mail Notification” checkbox and enter a valid email as in the screenshot.
Once you entered all, click the Save button and the 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 the next step is we need to add JDK and maven in Jenkins to run the build.
Click manage Jenkins, you will get the following screens.
Click Configuring system
Click Add JDK Button as in the screenshot
Once you click “Add JDK” following section will appear.
Deselect install automaticallycheckbox. Once you have done that, the 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” checkbox. You will get the following section.
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 the 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 the “Build Now” link inside navigation bar as in the above screenshot. Once you click “Build Now” link, your project build will start and shows a progress bar as in below screenshot.
If a build is completed the progress bar will disappear. Now click #1 link, it will show the build details as in the screenshot.
As per the 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 screenshot.
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 a 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 the 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