Handling Unexpected Closure of Testing Executions
post {
aborted{
echo '[Sealights] Cleanup executions left open.'
withCredentials([string(credentialsId: 'sl.agent.token', variable: 'SL_AGENT_TOKEN')]) {
sh '''
set +x
SL_DOMAIN="yourcustomdomain.sealights.co"
SL_AGENT_TOKEN=$(cat ./sl-agent-token.txt)
SL_LABID="MyLabID"
SL_TESTSTAGE="Functional Tests"
SL_TEST_EXECUTION_IDs=(`curl -sX GET "https://$SL_DOMAIN/sl-api/v1/executions?labId=$SL_LABID&testStage=$SL_TESTSTAGE&status=created" \
-H "Authorization: Bearer $SL_AGENT_TOKEN" \
-H "Content-Type: application/json" \
| jq -r '.data.list | map(.executionId) | join(" ")'`)
# Optional: filter based on Test Stage and/or LabID
echo "Found ${#SL_TEST_EXECUTION_IDs[@]} executions"
for id in ${SL_TEST_EXECUTION_IDs[@]}
do
echo -n "Closing Test Session ID $id: "
curl -isX DELETE "https://$SL_DOMAIN/sl-api/v1/test-sessions/$id" \
-H "Authorization: Bearer $SL_AGENT_TOKEN" \
-H "Content-Type: application/json" | grep HTTP
done
'''
}
}
}Last updated
Was this helpful?

