CodeShip
CodeShip pipelines run custom commands after a successful build, so a pipeline can trigger a Testsigma execution, wait for the tests, and hold deployment until they pass.
Prerequisites
- A CodeShip account with your organization, project, and source control (GitHub, Bitbucket, or GitLab) connected.
Configure the pipeline
Section titled “Configure the pipeline”-
Open the project: click Projects on the CodeShip home page and select your project. From the Dashboard, click Project Settings.
-
Choose custom commands: on the Configure your Tests page, select I want to create my own custom commands in the technology selector box.
-
Install jq: in the setup commands, enter
sudo apt-get install jq. The trigger script usesjq, a JSON query parser library for bash. -
Add a pipeline: click Add Pipeline and enter a name, for example
Testsigma Execution Trigger.
Add the trigger script
Section titled “Add the trigger script”Get the execution ID from the Testsigma executions page. Then replace <Execution-ID>, <Username>, and <Password> in the script with your values.
#!/bin/bash
echo "Triggering Execution!"
# Triggering an execution using the <Execution-ID> from Testsigma Execution details page. Use your account login details as <Username> and <Password>currentrunid=$(curl -sS -X POST -H 'Content-type: application/json' -u <Username:<Password> https://app.testsigma.com/rest/execution/<Execution-ID>/run)
echo "Started Execution. Waiting for tests to complete..."
currentstatus=1
#Use the Execution Status Check API and loop until the value of 'status' in the API Response equals to 0.while [ $currentstatus -ne 0 ]; do currentstatus=$(curl -sS -X GET -H 'Content-type: application/json' -u <Username:<Password> https://app.testsigma.com/rest/execution/<Execution-ID>/run/$currentrunid/status | jq '.status'); sleep 5; done
echo "Test Execution Completed. Checking results..."
#Get the value of 'result' from the API Response for Execution Status Check APIcurrentresult=$(curl -sS -X GET -H 'Content-type: application/json' -u <Username:<Password> https://app.testsigma.com/rest/execution/<Execution-ID>/run/$currentrunid/status | jq '.result')
echo $currentresult
#Check the result of the execution using Execution Status Check API - If the value of 'result' is 0, the test passed. Else, the test failed.if [ $currentresult -ne 0 ]; then echo "Test Failed. Please check Testsigma to know the reason for failure."; else echo "Test Passed! You may deploy now!"; fi
#Return the result as exit code - Non-zero value for execution result depicts Test failure and also triggers this script failure.$(exit $currentresult)-
Paste and save: paste the script into the new test commands box and click Save and go to Dashboard.
-
Add a build trigger: go to Project Settings > Build Trigger and add one.
-
Optional, add deployment: under Project Settings > Deploy, add the details of your deployment platform.
With these settings, every change to the repository triggers a build, and the build starts the tests in Testsigma. The script waits until the run completes and checks that the tests passed.
Was this page helpful?
Thanks for the feedback.