![](https://codenboxautomationlab.com/wp-content/uploads/2019/10/JenkinsImg.jpg)
Jenkins installation & Configure with Maven Project in local machine
Jenkins is an leading open source continuous integration server built with Java. It is used to build and test software projects continuously making it easier to integrate changes to the project. It provides 985 plugins to support building and testing virtually any project.
Install & Configure Jenkins:
-Search ” download jenkins ” or go to https://jenkins.io/download/
-Click on .war file (Generic Java package-2.190) to download due to install in local machine.
-Get the directory/ path of .war file (ex: C:\Users\SeleniumWork)
-Go to terminal/command prompt window. Type:cd +path of .war file (C:\Users\SeleniumWork) > java -jar jenkins.war -httpPort=8080
-Confirm to see message in command prompt as “Jenkins is fully up and running”
Unlocking Jenkins: Browse to http://localhost:8080
(or whichever port you configured for Jenkins when installing it) and wait until the Unlock Jenkins page appears.
![](http://codenboxautomationlab.com/wp-content/uploads/2019/10/jenkins-on-azure9.jpg)
![](http://codenboxautomationlab.com/wp-content/uploads/2019/10/jenkins-admin-password-1024x535.png)
- On the Unlock Jenkins page, paste this password into the Administrator password field and click Continue.
- Create Admin user as example below: UserName: Password : Full Name: Email:
- Confirm to get Jenkins url: http://localhost:8080/
3. Global setting: After login Click on Manage Jenkins>Global tool configuration>JDK installer and provide JAVA_HOME path from environment variable in the box(Or check automatically install to get your java environment information automatically by Jankin)
![](http://codenboxautomationlab.com/wp-content/uploads/2019/10/MavenJenkin26-1024x318.jpg)
-Scroll down & click Add Maven> provide MVN_HOME path from environment variable in the box(or check automatically install)> click on Save.
4. Add Maven Plugin: Click on Manage Jenkins> Manage Plugin> Under Available tab search ‘Maven> add all the maven plugin as:
- Maven Artifact
- Maven Metadata
- Maven Integration
- Maven Dependency
- Unleash Maven
- Maven Release plug-in
- Maven invoker plugin
- Maven repository scheduled cleanup
- Maven info plugin
click on Download and restart>Follow step number 7 to install TestNG Results plug.
5. Create Job: Click on New Item>Type item name (ex:MavenProject)>Select Maven plug-in>Ok>Go to ‘Pre-Steps’> copy the pom.xml directory path from your eclipse Project and past under ‘Root POM’ > type: ‘clean install’ under Goals and options> click on save.
6. Build and Run project: Click on Project>build>click on build now (Build#)>complete the build>console output>See the result. Note: you may need Oracle Account to login due to download the previous version JDK
7.TestNG Results plug in Jenkins: Login to Jenkins>Manage Jenkins> Manage Plug in>Search ‘testNG Result’ under available tab>Select TestNG Result>Install without restart>Finish installation. – Integrate TestNG XML report: Go back to the Project in Jenkins>configure>Select ‘Publish TestNG Results’ under ‘Post-build Actions’>Save
![](http://codenboxautomationlab.com/wp-content/uploads/2019/10/testng-results-selenium-jenkins.png)
8. Scheduling Jenkins Jobs for a specific time: To setup an schedule for a job/project due to build and execute the test we need to update our ‘Build Triggers’ in Jenkins. Go to the Project>Configure>Select ‘Build Periodically’ under Build Triggers and update/type our schedule (ex: 30 2 * * * )as per we need as bellow process and Save:
- MINUTES Minutes in one hour (0-59)
- HOURS Hours in one day (0-23)
- DAYMONTH Day in a month (1-31)
- MONTH Month in a year (1-12)
- DAYWEEK Day of the week (0-7) where 0 and 7 are sunday
![](http://codenboxautomationlab.com/wp-content/uploads/2019/10/Jankins-Build.jpg)
Since a few versions, Jenkins add a new parameter, H : (extract from the jenkins code documentation). To allow periodically scheduled tasks to produce even load on the system, the symbol H (for “hash”) 0 (zero) and * should be used wherever possible.
Note : * means every day/every month/every year. 0 means Zero th minute/hour . H means any or between time
Examples 1: The following are the main 5 parameters to set an schedule: M H D M DAYWeek 0 7 * * * (The job will run 0th minute at 7am every day/month/year ) 0 0 * * * (The job will spike 0th minute and 0th hour, means at midnight every day) 30 2 * * * (The job will run 2.30am on every day/month/year)
Example 2 : H H(3-4) * * * : A job which runs every Day of the week, every Month in a year , every Day in a month at a time between 3 – 4 am in the morning at any minute.
Example 3 : H (30 -45) 3 * * * : A job which runs every Day of the week, every Month in a year , every Day in a month at 3 am in the morning between 30 -45 minutes.
Example 4 : */5 * * * * : If you want to schedule your build every 5 minutes, this will do the job
Example 5 : 0 8 * * * : schedule your build every day at 8h 00, this will do the job