Scriptworks Logo

Running Tests from Jenkins

15 Mar 2019

Scriptworks provides a feature to launch test execution from a command line using curl. Full documentation can be found here

This feature allows for integration with CI tools such as Jenkins, and allows test results to contribute to indications of Build health.

Launching Tests

Launching tests can be achieved by adding a Build Step in Jenkins as follows:

  1. Add an "Execute Shell" (Linux/MacOS) or "Execute Windows batch command" shown below.

2. For Jenkins on Linux/MacOS the Command Line call using curl can be entered directly into the Shell command field as shown:

This can be used with any of the supported parameters documented for the Command Line Execution feature here

Two useful options for linking Scriptworks results with a Jenkins Build and displaying results in Jenkins are shown below:

Using the Jenkins Build Number as Run Name

The Run Name feature in Scriptworks can be useful as a way of linking results in the Scriptworks Dashboard with a Jenkins Build for analysis purposes:

This can be achieved by incorporating Jenkins Environment Variables into the call to the Scriptworks Command Line an example is shown below:

curl -d '{"runName": "Jenkins Build: '"$BUILD_DISPLAY_NAME"'","apiUrl": "", "projectId": 89, "testIds":[253,2004,2003], "runSettingIds":[56],"username": "myuser","password": "mypass","outputFormat": "JUnit"}' -H "Content-Type: application/json" -X POST '' -o Results.xml

Note - The use of the Quotes surrounding the Environment Variable are important.

Results reporting in Jenkins

To enable Jenkins to process test results and report on Build Health the call to the Scriptworks command line should incorporate the outputFormat parameter set to JUnit and the results should be output to a file for processing using the -o <filename>.xml switch. A full example of such is shown below:

curl -d '{"runName": "Jenkins Build: '"$BUILD_DISPLAY_NAME"'","apiUrl": "", "projectId": 89, "testIds":[253,2004,2003], "runSettingIds":[56],"username": "myuser","password": "mypass","outputFormat": "JUnit"}' -H "Content-Type: application/json" -X POST '' -o Results.xml

The results themselves are processed by Jenkins as a Post-Build action as shown below:

  1. Add a Post Build Action to "Publish JUnit test result report":

2. The name of the output file should be added into the step itself:

Results will then appear on the Jenkins Dashboard:

Clicking on the Chart will open the report detail showing any Failed tests:

Additional Test Detail can be obtained from the Scriptworks dashboard and clicking on the Sessionid of the test:

Any screenshots or screen recordings (in conjunction with Cloud providers such as Saucelabs) will be shown in the detail:

Scriptworks logo
© Copyright 2024 | Scriptworks is part of Odin Technology Ltd, a company registered in England no. 03735083