Jenkins Configuration


Download Jenkins Java Web Archive (.war) file from below path
https://jenkins-ci.org/
How to start Jenkins ->Go to command prompt
And navigate to where war file was downloaded
For example your placed in E:\software\selenium
Navigate to that folder
And use below command for running (Note for jar and war we should use java –jar only)
Java –jar jenkins.war and press enter
It will take some time to start Jenkin service
Screen looks like thisclip_image002
Then open a browser and type below url
http://localhost:8080 (note: bydefault port is 8080)
if screen is look like this means Jenkin is up and running
clip_image004
How to Configure in Jenkin
1) Click in Manage Jenkinà screen looks like this
clip_image006
2) Click on Configure systemà screen looks like
clip_image008
As of now only given java path in JDK Section
3) Click on JDK Installations button
4) Enter Name -> JAVA_HOME
5) Enter path -> where java is installed (Ex: C:\Program Files\Java\jdk1.7.0_51)
Note: Install automatically check box is checked by default , please uncheck it otherwise java updates will happen.
6) Apply then Save
1) Create small java programme in eclipse
clip_image010
2) Create testng xml file
clip_image012
Try to run this programme from command before running from Batch (Jenkins)
1) Go to command prompt
2) Navigate to where your java program is
Create one libs folder and copy all jar files into that (all Selenium jar files)
clip_image014
Before running the TestNg xml file from command prompt you should set the class path
3) Set the class path for bin and libs
 
image
Once set the class path give the run command
Java org.testng.TestNG testng.xml
image
Next step is to create a batch file
Open new notepad
Enter below command in notepad
java -cp bin;libs/* org.testng.TestNG testng.xml
clip_image020
And save it as .bat file with double codes (Ex: “RUN.bat”)
Then double click on .bat files
Output is looks like this
clip_image022
Next step is to create a job
Goto Jenkins window
1) Click on New Item
2) Enter the item name and select freestyle project radio button.
clip_image024
3) click on ok button
4) click on Advance project options
clip_image026
clip_image028
5) select use custom workspace then enter directory name where your batch file is available
clip_image030
Next Step is Build
clip_image032
1) Click on Add build step
2) Select Execute windows batch command
3) Enter the batch file name
clip_image034
Our batch file name is “RUN.Bat”
4) Then click on apply and Save
5) Now our job is ready for execute
6) Now click on Build Now link
clip_image036
You will get the build history
clip_image038
History index will keep on increase whenever you will run build
User wants to see the console output
Click on index number (Ex: #2) , screen looks like this
clip_image040
Then click on Console Output link then output is looks like
clip_image042
Schedule a Job
click on configure link
1)select Build periodically check box
clip_image044
Enter the pattern (means hourly, monthly etc...) (Note: click on? you will get the pattern examples)
This field follows the syntax of cron (with minor differences). Specifically, each line consists of 5 fields separated by TAB or whitespace: MINUTE HOUR DOM MONTH DOW
MINUTE Minutes within the hour (0–59)
HOUR The hour of the day (0–23)
DOM The day of the month (1–31)
MONTH The month (1–12)
DOW The day of the week (0–7) where 0 and 7 are Sunday.
For example if every five minutes build will trigger , you should specify like that
H/5 * * * *
For example:
if you want to schedule your build every day at 8h00, this will do the job : 0 8 * * *
clip_image046
clip_image048
Note: Enter space between * and *
Then click on apply and save











Comments