Thursday, January 14, 2016

How to Set Up Jenkins CI Server with TestNG and Gradle plugin

Download and installation

  1. Download Java .war file from Jenkins-ci.org








  1.   Open command prompt as administrator
  2.   Run the following command to start Jenkins service                                                                      Java –jar Jenkins.war                                                                                                                   Note:  You have to be in the same path as where the .war file was downloaded to run the command
  3. By default, Jenkins runs on port 8080.
  4.            Once the service is started, open a browser and hit localhost:8080
  5.  . .     If there is any other service, using the 8080 port already then Jenkins will not run or open.
  6.      .    In that case, change the port for Jenkins in command prompt by running the following command.
  7.         Java -jar Jenkins.war –httpPort=909
  8.          After this launch browser and hit localhost:<portNo.> where <portNo> is the port given by you in the command                                                                                                                                   The Jenkins interface should load in the browser as shown below:

Plugin installation

1.       Click on Manage Jenkins link
2.       Click on Manage Plugins in the following page:











1.       Navigate to ‘Available’ tab
2.       Search for ‘TestNG , Gradle , GitHub  in the search bar or scroll down to ‘External Site/Tool Integrations’ section
3.       Select the All the required Plugin checkbox and click on ‘Download now and install after restart’
4.       Once you get a success message, close the browser and .cmd prompt
5.       Repeat steps 2-8 to restart Jenkins for the plugin to be activated
6.       To verify if the plugin is installed correctly, navigate to Manage Jenkins > Manage Plugins > Installed tab and check if TestNG, Gradle , GitHub plugin is displayed and ‘Enabled’ checkbox is ticked




     Creating Job

1.       On the main dashboard, click on ‘create new jobs’
2.       The following options are displayed:











·         Provide a name for the job and select appropriate job.
·         To run a Java Selenium based project, a freestyle project should suffice.
·         We can also select ‘Build multi-configuration project’ if we are configuring the job to run for multiple configurations, environments etc.
1.       In the configuration window that gets displayed, provide a meaningful description
2.       Scroll down to ‘Build’ section
3.       Setting GIT repository and branch.













S   Setting Build trigger Time:

     



    Invoking Gradle Section:












            In the ‘Post-build Actions’, click on ‘Add post-build action’ button to add several actions to be done after triggering the job
·         Add ‘Archive the artifacts’. Provide the location of the TestNG report HTML and XML files.
·         Add ‘Incorporate TestNG Results’. Select both the check box options to display trend graphs of average response time and error rate %.











1.       Save the job
2.       Run:  Go to Jenkins home page. Search created job open it and click on “Build Now” link.

     

   Running Jenkins slave on different machine

By default, Jenkins will trigger the job on the same machine as the installation. So when a job is triggered, it will use the same machine’s CPU and memory. This can lead to choking when multiple jobs are triggered for different configurations/environments.
In order to avoid this, we can configure Jenkins Slaves. In other words, we can program Jenkins to run the jobs on other machines (which would become ‘slaves’ to the ‘master’ system). There is no need to install Jenkins on the slave machines.
Steps can be found here.

   Viewing results

Navigate to the job created and click on Build Now.
Once the build has completed successfully, navigate to the build number and click on it.

No comments:

Post a Comment