Jenkins Integration – Simple Project

Jenkins Configuration

Bear in mind that the next steps we will configure a simple job that runs on Jenkins’ machine

Go to Jenkins -> Manage Jenkins -> Jenkins Configuration. This page allows us to configure Jenkins’ basic configuration

JDK
  1. Under JDK click JDK Installation
  2. Click on Add JDK
  3. Fill the local machine JAVA_HOME path and give the JDK installation a name.

In this point there is no need to configure more than one JDK, but you can click “Add JDK” and add as much JDK installation as you please.

Maven

Jsystem project are built with Maven, Jsystem also has a maven plugin for Jenkins.

  1. Under Maven click “Maven Installations”
  2. Click Add Maven
  3. Click Add Installer and select “Install from Apache”
  4. Give the installer a name
  5. Check “Install Automatically” and select the Maven version (I prefer 3.0.4)

Click Save

Basic Job Configuration

Jenkins has some different job templates, although we will use Maven I prefer to use the “free-style software project” and not “maven2/3 project”. I find the free-style project more flexible and easy to use.

  1. On Jenkins’ main screen click on “New Job”
  2. Select “Build a free-style software project” and name the job
  3. Click “Ok”
Source Code Management

In this case we will configure SVN but Jenkins can handle all kind of SCMs but most of them will require a plugin.

Check Subversion and fill in the proper URL – that should do the trick…

Build Steps

To build and run our project we will need to add some build steps.

  1. Click “Add Build Step”
  2. Choose “Invoke top-level Maven targets”
  3. Choose the maven version you have configured
  4. For infra project the target should be “clean install”
  5. Click “Advanced”
  6. If your pom file is not on the root folder of the project you should fill its location and name in the “POM” text box
  7. For test project repeat steps 1-6
    • this time the target will be clean install org.jsystemtest:jsystem-maven-plugin:run -Dscenario=scenarios/default -Dsut=default.xml
    • you can find further information in http://jsystem.org/jsystem-maven-plugin/
    • change the POM location as well

Click Save

Reporting

Jsystem generates by default two reports : HTML report and JUnit XML report, we will add both to the job.

JUnit
  1. Under “Post-build Actions” click “Add post-build action”
  2. Select “Publish JUnit test result report”
  3. Fill the JUnit XML path, it’s locate at <test project>\log\current\*.xml

Jenkins can parse JUnit report and the result will be shown on the main screen of each build. The result will also determine the build’s status (Success, Unstable and Fail)

HTML Report

To enable HTML report:

  1. Go to Jenkins -> Manage Jenkins -> Manage Plugins
  2. Click on the “Available” tab
  3. Search for “HTML Publisher plugin” (there is search box on the upper right corner of the page)
  4. Mark the plugin and click “Install without restart”
  5. Restart Jenkins http://Jenkins-url/restart
  6. Enter the job’s configuration
  7. Under “Post-build Actions” click “Add post-build action”
  8. Select “Publish HTML reports”
  9. The HTML report path is test-project\log\current
  10. Mark Keep past HTML reports
  11. Report title is the name of the link that will be shown on the job’s main screen, you can edit it as you please.

Click Save

Conclusion

We configure a simple job that checkouts the automation code from the source control, builds the infra project, builds and run the test project with a given scenario and SUT (hard coded in the job’s configuration for now) , reports the result of the test by parsing the JUnit XML result file and attaches the Jsystem HTML report to the build.

 

Nir Armon
View Nir Armon's LinkedIn profileView Nir Armon’s profile

 

Fork me on GitHub