Continuous Integration
You can integrate Zephyr Squad using continuous integration (CI) for two different benefits:
Download and execute Cucumber/BDD test cases - optional, only you use Cucumber.
Upload automated test results to Zephyr Squad, making that information available in Zephyr Squad to manage all testing efforts from one place.
Windows users must download and install Curl and 7-zip and add both system paths to their machines. More information about how to update system path variables is here.
The following instructions are compatible with any CI platform that is able to run bash scripts as a build step.
First Step (optional): Download Cucumber/BDD Test Cases from Zephyr Squad:
Note
This is an optional step. Move to the next step if you don’t use Cucumber/BDD.
For more information about how the Zephyr Squad Cucumber integration works, please visit Cucumber Integration.
When you use Cucumber/BDD test cases with Zephyr Squad, all scenarios are stored within Zephyr Squad, and that represents the single source of truth for scenario definition. In order to run these test cases, a CI platform has to download all of these Cucumber/BDD test cases in the form of Cucumber/BDD Feature Files.
Once feature files are downloaded, they can be executed using Cucumber, producing test results. Then, the test result files can be uploaded to Zephyr Squad so that all results can be managed within Zephyr Squad (see next step).
The following scripts are an example of how to download feature files. You can use these or similar scripts as part of your continuous integration pipeline:
Windows users:
set ZEPHYR_SQUAD_API_URL="https://prod-api.zephyr4jiracloud.com/v2" set ZEPHYR_SQUAD_API_KEY=%zephyr_squad_api_key% set PROJECT_KEY="WEB" set BUILD_DIR=%working_directory% set TARGET_PATH="src/test/resources/features" set ZIP_FILE="bddfile.zip" echo "Clean target path" rm -rf %BUILD_DIR%/%TARGET_PATH% mkdir -p %BUILD_DIR%/%TARGET_PATH% echo "Downloading feature files" curl -H "Authorization: %ZEPHYR_SQUAD_API_KEY%" %ZEPHYR_SQUAD_API_URL%/automations/testcases?projectKey="%PROJECT_KEY%" --output %BUILD_DIR%/%TARGET_PATH%/%ZIP_FILE% echo "Unzipping feature files" 7z e -aoa %BUILD_DIR%/%TARGET_PATH%/%ZIP_FILE% -d %BUILD_DIR%/%TARGET_PATH% echo "Finished"
UNIX Users
ZEPHYR_SQUAD_API_URL="https://prod-api.zephyr4jiracloud.com/v2" ZEPHYR_SQUAD_API_KEY=$zephyr_squad_api_key PROJECT_KEY="WEB" BUILD_DIR=$working_directory TARGET_PATH="src/test/resources/features" ZIP_FILE="bddfile.zip" echo "Clean target path" rm -rf $BUILD_DIR/$TARGET_PATH mkdir -p $BUILD_DIR/$TARGET_PATH echo "Downloading feature files" curl -H "Authorization: $ZEPHYR_SQUAD_API_KEY" $ZEPHYR_SQUAD_API_URL/automations/testcases?projectKey="$PROJECT_KEY" --output $BUILD_DIR/$TARGET_PATH/$ZIP_FILE echo "Unzipping feature files" unzip $BUILD_DIR/$TARGET_PATH/$ZIP_FILE -d $BUILD_DIR/$TARGET_PATH echo "Finished"
Second Step: Send Test Results to Zephyr Squad
Once all automated tests are executed in your CI, in order to transfer your test execution results to Zephyr Squad, you need a final script task to upload the test results to Zephyr Squad.
Add one of the following scripts to your build pipeline, and remember to replace the PROJECT_KEY and ZEPHYR_SQUAD_API_KEY variables with your actual information. Optionally, you can replace the PATH_FILE, ZIP_FILE, and AUTO_CREATE_TEST_CASES variables with your information.
Depending on whether using Cucumber, JUnit or Custom Format, you can use different API endpoints when uploading the results using the curl
command. Please, check our API documentation for more details.
Windows User - Uploading Cucumber Test Results
@echo off set ZEPHYR_SQUAD_API_URL=https://prod-api.zephyr4jiracloud.com/v2 set ZEPHYR_SQUAD_API_KEY=%zephyr_squad_api_key% set PROJECT_KEY=WEB set BUILD_DIR=%working_directory% set FILE_PATH=target\cucumber\*.json set ZIP_FILE=test_result.zip set AUTO_CREATE_TEST_CASES=true echo Removing old zip files if exist "%BUILD_DIR%\%ZIP_FILE%" del /F /Q "%BUILD_DIR%\%ZIP_FILE%" echo Creating new zip file 7z a "%BUILD_DIR%\%ZIP_FILE%" "%BUILD_DIR%\%FILE_PATH%" echo Sending zip file to Zephyr Squad curl -H "Authorization: %ZEPHYR_SQUAD_API_KEY%" -F "file=@%BUILD_DIR%\%ZIP_FILE%;type=application/x-zip-compressed" %ZEPHYR_SQUAD_API_URL%/automations/executions/cucumber/%PROJECT_KEY%?autoCreateTestCases=%AUTO_CREATE_TEST_CASES% -v echo Finished
UNIX User - Uploading Cucumber Test Results
ZEPHYR_SQUAD_API_URL="https://prod-api.zephyr4jiracloud.com/v2" ZEPHYR_SQUAD_API_KEY=$zephyr_squad_api_key PROJECT_KEY="WEB" BUILD_DIR=$working_directory PATH_FILE="target/cucumber/*.json" ZIP_FILE="test_result.zip" AUTO_CREATE_TEST_CASES="true" echo "Removing old zip files" rm -f $BUILD_DIR/$ZIP_FILE echo "Creating new zip file" zip $BUILD_DIR/$ZIP_FILE $BUILD_DIR/$PATH_FILE -j echo "Sending zip file to Zephyr Squad" curl -H "Authorization: $ZEPHYR_SQUAD_API_KEY" -F "file=@$BUILD_DIR/$ZIP_FILE;type=application/x-zip-compressed" $ZEPHYR_SCALE_API_URL/automations/executions/cucumber/$PROJECT_KEY?autoCreateTestCases=$AUTO_CREATE_TEST_CASES -v echo "Finished"