Handling global failure in CI

Applies to CucumberStudio Cloud, and to Enterprise ver. 3.3 - 3.5.6.0. Last updated on November 17, 2023

When integrating CucumberStudio with a CI tool, it may happen that the test run is not fully synchronized with the status of the last build. This mainly happens when the tests have not been ran (for example due to an installation or compilation error during the setup process).

In such case, as there is no test results to push at the end of the build, CucumberStudio consider only the status from the previous build. So it might still show green statuses even if the last build failed.

There is a simple way to fix this kind of issues.

When pushing results with HipTest Publisher

If you use HipTest Publisher to generate the test scripts and push the results, you can simply add the following line in you config file:

global_failure_on_missing_reports = true

This will ensure that, when no results file have been generated, CucumberStudio will be notified that there were a global failure and the tests will all be marked as failed.

Note: You should only add the line once the full process has been shown as reliable (so once you have a few successful builds that pushed results back to CucumberStudio).

When pushing results with curl

If you want to push results for tests that were not written in CucumberStudio, you can use another curl command to notify a global failure of the build.

Below is an example of a post-failure action written with bash:

#!/bin/bash
 
FILE=<path to you result file>
SECRET_TOKEN=<your CucumberStudio secret token>
TEST_RUN_ID=<the test run to which you want to push results>
 
if [ -f $FILE ]; then
  curl -X POST -F file=@$FILE https://hiptest.net/import_test_reports/$SECRET_TOKEN/$TEST_RUN_ID/junit
else
  curl -X POST https://hiptest.net/report_global_failure/$SECRET_TOKEN/$TEST_RUN_ID/
fi

This script ensures that, if the result file is present, it will be pushed to CucumberStudio to update the results in the test run and otherwise, declare a global failure.

Highlight search results