Jenkins is an Open Source Continuous integration tool that is written in Java which is often used in Devops.
It is mainly used by Developers and Testers, whenever Developers/Testers does any changes in Source Code then Jenkins will automatically pull the code and continuously build and test code that has been added.
Step 1: Installing Jenkins War File.
Follow below steps to install Jenkins War File.
Go to any browser and search by Jenkins Download as shown below and click on below highlighted link.
After clicking on above highlighted link, you will be navigated to below page.
Click on “Permalink to the latest” – Latest and Stable version of Jenkins War File will be installed into your local system.
Now you are good to execute your Jenkins War File from Command Prompt.
Step 2: Executing Jenkins War File from Command Prompt.
Create a separate folder in your local system and place Jenkins War file once it is downloaded. Note: We must run Jenkins.war file through Command Line Prompt.
Step 3: Use below command to Run Jenkins.war file
Note: By default, Jenkins will always run in localhost:8080. Make sure nothing else is running on port 8080. If localhost:8080 is already occupied then you won’t be able to execute Jenkins.war file. In such case you can execute your Jenkins.war file in other port using below command.
Once Jenkins is successfully launched, user should be able to see below message in
“Jenkins is Fully Up and Running”.
Step 4: Now, go to browser and open localhost:8084 where you have run your Jenkins.
In my case, I have run Jenkins in port 8084.
When launching it for first time, you have to set username and password and install default plug-ins that suggests etc and then you will be landed on to Jenkins Dashboard Page.
Step 5: Configure your system for Java and Maven in Jenkins as shown below
Go to Manage Jenkins >> Global Tool Configuration.
Step 6: Install Required Plug-ins >> Go to Manage Jenkins >> Manage Plug-ins and install from Available Section.
Step 7: Create Job >> New Item >> Enter Item Name >> Select Maven Project and Click on OK. After installing all Maven Plug-ins user should be able to see Maven Project Option.
Step 8: A. Go to General >> Enter Description of your Project.
B. Go to Maven Info Plug-in Configuration >> Select None.
C. Go to Source Code Management. [You have to select any one option from it].
Select None, if you are not using any Source Code Management tool for maintaining Code.
Select Git and provide Repository URL and Branch Name, if you are maintaining code in Git.
D. Go to Build Triggers.
You can select as shown below, if you are not scheduling jobs using CRON Command and such. [In this case you have to build a job manually].
If you have to schedule jobs automatically, select Build Periodically and use CRON Command.
If we have to build a job automatically when in any commit happens to Git then we
can select Poll SCM and use CRON Command.
[As soon as code commit happens to Git, it will trigger a build].
E. From Build Environment, Select None
F. From Pre Steps, Select None.
G. From Build, Enter Path for your Root POM.xml and command to be executed as shown below.
Note: When in giving Maven Command to Run Test Cases in Jenkins, ignore mvn and just give commands as below.
clean install Or test Or test -PSmoke etc.
H. From Post Steps, you can select any option as per your requirement.
I. If you want to be notified, when in any job is getting failed then you can select Build Settings and configure it.
Note: To do this we need to do other extra configuration [You can ignore for it now].
J. Post Build Actions can be used to Generate Results. [To achieve it, we need to install required plug-ins like TestNG Plug-in, HTML Report Plug-in for Generating Extent Report]
Below Configurations needs to be done for generating Extent Reports in Project Folder.
Step 9: Apply and Save, now click on Build now to trigger your Job.
Conclusion: In this blog, we have seen how to create a Job for Maven Project, Configuring Job and Executing a Job in Jenkins.
Author: Pavan K
Pavan, having good knowledge in Selenium Web UI and API Automation frameworks. Also, he is helping QA community with his knowledge along with Naveen AutomationLabs!!
Reviewer: Naveen Khunteta
Leave a Reply