Continuous Integration with Jenkins : A beginners guide

Continuous integration is a process in which all development work is integrated  at a predefined time or event and the resulting work is automatically tested and built. Jenkins is one open source tool to perform continuous integration.

> Step by step process to install and configure Jenkins with your scripts

  1. Install “Jenkins.war”  http://mirrors.jenkins-ci.org/war/latest/   file in your system

  2. Keep .war file where you have your workspace for example C:\Users\xyz\workspace so keep your “jenkins.war” at  C:\Users\xyz\jenkins.war

  3. Then open command prompt (cmd) and type “Java –jar jenkins.war “ and run it (Make sure JDK is already install in your computer).

  • Make sure “.Jenkins” folder is created after running this command.

  1. Open your browser and give localhost url :-> localhost:8080

  2. Now go to Manage Jenkins-> configure system -> set JDK ,ANT/ Maven values as set below.

      JDK :: Uncheck “install automatically” to get Java_Home field.

     Jdk name

  Java_homeC:\Users\Lenova-3831\Desktop\Blog\Jenkins_Integartion\FireShot Screen Capture #017 - 'Configure System [Jenkins]' - localhost_8080_configure.png

  1. If you are using ANT(Another Neet Tool) then set ANT name as “ Apache Ant “ . Shown belowC:\Users\Lenova-3831\Desktop\Blog\Jenkins_Integartion\FireShot Screen Capture #018 - 'Configure System [Jenkins]' - localhost_8080_configure.png

  2. If you are using Maven Uncheck “install automatically” to get Maven_Home field.C:\Users\Lenova-3831\Desktop\Blog\Jenkins_Integartion\FireShot Screen Capture #019 - 'Configure System [Jenkins]' - localhost_8080_configure.png

       Type Maven_Home path here.

       Now click on “save ” button

  1. After configuring Jenkins , Create a new job

  2. Give your project name and If you are building a maven project  then choose “Build a maven 2/3 Project” or if you are building a Ant project then choose “Build a free-style software project”

  3. Go to “Build” under your created job ->  add build step choose “Invoke ant” (If your project Is build using Ant) or choose “Invoke top-level Maven targets” (If your project is build using Maven) C:\Users\Lenova-3831\Desktop\Blog\Jenkins_Integartion\Build.png

          If it is Ant then you have to set the field

          Ant version :: Apache Ant

         Target ::  RunAndViewReport

 BuildPath ::  your script pathC:\Users\Lenova-3831\Desktop\Blog\Jenkins_Integartion\Invoke Ant.png

  1. Click on save button

  2. Now run your first build by clicking on “Build now” You will see  that it will get fail first time Don’t worry , it is a part of your process.

  1. Now go to your workspace -> open the folder  “.Jenkins” . -> Copy your all scripts into .jenkins/workspace/”Name of your job” and refresh the Jenkins.

  2. Go to your job -> workspace -> Make sure  your projects file all there in workspace now

  3. Now run the build again. (If you are running your scripts in chrome browser then give proper path of your chrome driver)

             And you are done with Selenium Integration with Jenkins

     >Additional 

         How to schedule

        job configuration-> “Build Triggers”, ->”build periodically” field

    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

    I just tried to get a job to launch at 4:42PM (my approximate local time) and it worked with the following, though it took about 30 extra seconds:

    42 16 * * *

    42 16 * * *

     If you want multiple times, I think the following should work:

     0 16,18,20,22 * * *

     for 4, 6, 8, and 10 o’clock PM every day.

 How to send email automatically after completing a job

    Set Configuration as shown below:


C:\Users\Lenova-3831\Desktop\nitesh.jpg

Now you are done with integration of your selenium scripts with Jenkins.