Running Gwen Workspaces on Jenkins

In this post I’m going to walk though the basics of getting a Gwen Workspace up and running on Jenkins.

Prerequisites

Be sure you have following setup before proceeding..

  • A running Jenkins environment with
    • Java 1.8+ installed
    • A browser installed (preferably Chrome)

Create a Gwen Workspace Repository

Next, you will need to convert your Gwen project over to a Gwen Workspace. If you have not already done this it is easy to do. Just follow these steps:

  • Download and unzip the latest gwen-workspace.zip to a location on your drive
  • Copy all your .feature and .meta files to the features folder.
  • Copy any common Gwen meta files required by all features to the meta folder (optional)
  • Check that your features execute successfully by running gwen features -b in the workspace root
    • You can tweak any Gwen properties or wrapper scripts in the workspace if required to tailor your execution.
  • Publish your workspace folder to your Git repository

The benefit of using a workspace is that it contains an embedded Gwen Package Manager that will automatically install Gwen and any native web drivers for you (so you don’t have to do this manually in the Jenkins environment). If you do not want to use a workspace but would rather utilise your current project setup “as is”, then you will have to do manual installation and configuration work on the Jenkins host to ensure that your features can execute (but the basic setting up of the Jenkins job will be similar to below).

Create a Jenkins Job

Once you have a workspace that is accessible from Git, you are ready to create a Jenkins job to run your workspace.

  • Logon to your Jenkins
  • Create a new “Freestyle” project and give it a name
  • In the “Source Code Management” section, select “Git” and provide your Gwen workspace repository URL and other Git settings
  • In the “Build” section, select “Execute Shell” (for linux) or “Execute Windows Batch Command” (for windows), and enter the following command to run Gwen
    • Linux: ./gwen features -b -f junit -Dgwen.web.browser.headless=true
    • Windows: gwen features -b -f junit -Dgwen.web.browser.headless=true

    -b tells Gwen to exit once execution is complete, -f junit tells Gwen to generate JUnit-XML reports, and -Dgwen.web.browser.headless=true tells Gwen to run the browser in headless mode. You can also pass additional Gwen options if required, like --parallel for example if you want to utilise all cores and perform parallel execution.

  • In the “Post-build Actions” section, select “Publish JUnit test result report”, and enter the following in the “Test Report XMLs” field.
    • target/reports/junit/TEST-*.xml
  • Click “Save” when you are done and then run your job

That’s it!!

Advertisements

Published by

Branko Juric

Imperative by day and functional by night. Co author of the Gwen automation platform.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s