Integration with Jenkins

Get results of executed test cases updated in TestCollab using Jenkins

Vishal Vaswani avatar
Written by Vishal Vaswani
Updated over a week ago

In this article we would see how can the results for executed test case be updated in TestCollab automatically after it has been executed using Jenkins.

Jenkins have been one of the most popular CI/CD platforms for obvious reasons :

  • being open source

  • having support for plugins for almost all purposes

Jenkins Job

We will have a freestyle project with simple shell script. We will use TestCollab API for testing and for updating results back into the application.

The shell script would be performing the following jobs:

  • Try to delete a project on a TestCollab account using API token of a limited rights user

  • Compare the http_code returned by the above API call, if it is greater than or equal to 400 and lesser than 500 then our test case will be considered as passed

    • Call TestCollab API endpoint to update the executedtestcase will be invoked using API token of a user who has right to do so

  • If any other http_code is returned then our test case would fail

    • Call TestCollab API endpoint to update the executedtestcase will be invoked using API token of a user who has right to do so

The script

#delete a project through TestCollab API using credentials of a limited rights user

curl_status=$(curl --write-out %{http_code} --silent --output /dev/null 'https://api.testcollab.io/projects/12483?token='$API_User -X DELETE)

if ([ $curl_status -ge 400 ] && [ $curl_status -lt 500 ]) then
#set status as passed for test case
curl 'https://api.testcollab.io/executedtestcases/2530688?token='$API_Admin --compressed -X PUT -H 'Content-Type: application/json' --data-raw '{"test_plan_test_case":2476910,"project":"466","test_plan":39961,"test_plan_config":null,"comment":"passed","status":1,"step_wise_result":[]}'
else
#set status as failed for test case
curl 'https://api.testcollab.io/executedtestcases/2530688?token='$API_Admin --compressed -X PUT -H 'Content-Type: application/json' --data-raw '{"test_plan_test_case":2476910,"project":"466","test_plan":39961,"test_plan_config":null,"comment":"failed","status":2,"step_wise_result":[]}'
fi

Please note that API_User and API_Admin have been stored as global environment variables on Jenkins instance used.

Build

Did this answer your question?