Handling Unexpected Closure of Testing Executions
post {
aborted{
echo '[Sealights] Cleanup executions left open.'
withCredentials([string(credentialsId: 'sl.agent.token', variable: 'SL_TOKEN')]) {
sh '''
set +x
SL_SESSION_IDs=(`curl -sX GET "https://$DOMAIN/sl-api/v1/executions?bsid=$BSID&status=created" \
-H "Authorization: Bearer $SL_TOKEN" -H "Content-Type: application/json" \
| jq -r '.data.list | map(.executionId) | join(" ")'`)
#Optional: filter based on the Test Stage name and/or labId (especially relevant in case of parallel testing)
echo "Found ${#SL_SESSION_IDs[@]} executions"
for id in ${SL_SESSION_IDs[@]}
do
echo -n "Closing Test Session ID $id: "
curl -isX DELETE "https://$DOMAIN/sl-api/v1/test-sessions/$id" \
-H "Authorization: Bearer $SL_TOKEN" -H "Content-Type: application/json" | grep HTTP
done
'''
}
}
}Last updated
Was this helpful?

