Configuring Jenkins for continuous integration

Jenkins is a popular continuous integration server in the Java development community. It is derived from the Hudson CI server. It supports SCM tools including CVS, Subversion, Git, Mercurial, Perforce, and ClearCase, and can execute Apache Maven and Apache Ant-based projects, as well as arbitrary shell scripts and Windows batch commands.

Jenkins can be deployed to set up an automated testing environment where you can run Selenium WebDriver tests unattended based on a defined schedule, or every time changes are submitted in SCM.

In this recipe, we will set up Jenkins Server to run Maven and Ant projects. Later recipes describe how Ant and Maven is used to run Selenium WebDriver tests with Jenkins.

Getting ready

Download and install the Jenkins CI server from http://jenkins-ci.org/. For this recipe, the Jenkins Windows installer is used to set up Jenkins on a Windows 7 machine.

How to do it...

Before using Jenkins, we need to set up the following options in the Jenkins configuration:

  1. Navigate to Jenkins Dashboard (http://localhost:8080 by default) in the browser window.
  2. On Jenkins Dashboard, click on the Manage Jenkins link.
  3. On the Manage Jenkins page, click on the Configure System link.

Adding JDK

The following are the steps for adding the JDK:

  1. On the Configure System page, locate the JDK section.
  2. Click on the Add JDK button in the JDK section.
  3. Specify JDK8 in the Name field and unselect the Install automatically checkbox.
  4. In the JAVA_HOME textbox, enter the path of the JDK folder from your system. In the following screenshot, C:Program FilesJavajdk1.8.0_25 has been specified:
    Adding JDK

Adding Ant

  1. On the Configure System page, locate the Ant section.
  2. Click on the Add Ant button in the Ant section.
  3. Specify Ant in the Name field and unselect the Install automatically checkbox.
  4. In the ANT_HOME textbox, enter the path of the Ant folder from your system. In the following screenshot, C:Program FilesWinAnt has been specified for the WinAnt version:
    Adding Ant

Adding Maven

Follow the given steps to add Maven:

  1. On the Configure System page, locate the Maven section.
  2. Click on the Add Maven button in the Maven section.
  3. Specify Maven in the Name field and unselect the Install automatically checkbox.
  4. In the MAVEN_HOME textbox, enter the path of the Maven folder from your system. In the following screenshot, MAVEN_HOME contains C:apache-maven:
    Adding Maven
  5. Click on the Save button to save the configuration.

There's more…

Jenkins also runs a Selenium standalone server that can be used as a remote web driver. Using Jenkins master/slave architecture, we can build a distributed build and test environment for large-scale test automation projects.

See also

  • The Using Jenkins and Maven for Selenium WebDriver test execution in continuous integration recipe
  • The Using Jenkins and Ant for Selenium WebDriver test execution in continuous integration recipe
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.228.88