You can integrate with CI pipelines using the REST API.
1. Using the REST API
You can trigger a Test Run and query its results using the REST API.
Please refer to the REST API Usage guide.
2. Github Actions
To use the example below as is, RELIV_API_KEY
must be registered in Github Secrets.
You can change the env to whatever environment you wish to use.
Additionally, to prevent it from running indefinitely due to unforeseen reasons, a timeout of 10 minutes has been set. You can adjust this as needed.
- name: Trigger Reliv Tests
id: trigger-reliv-tests
run: |
RESPONSE=$(
curl -s -X POST 'https://api.reliv.ai/api/v0/test-run-sets' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ${{ secrets.RELIV_API_KEY }}' \
-d '{"env": "default"}'
)
echo "testRunSetId=$(echo $RESPONSE | jq --raw-output '.testRunSetId')" >> $GITHUB_OUTPUT
- name: Check Reliv E2E Test Status
timeout-minutes: 10
run: |
while true; do
RESPONSE=$(
curl -s -X GET 'https://api.reliv.ai/api/v0/test-run-sets/${{ steps.trigger-reliv-tests.outputs.testRunSetId }}' \
-H 'Authorization: Bearer ${{ secrets.RELIV_API_KEY }}'
)
STATUS=$(echo $RESPONSE | jq --raw-output '.status')
case $STATUS in
SUCCESS)
echo "Test Status: SUCCESS"
exit 0
;;
FAIL)
echo "Test Status: FAIL"
exit 1
;;
*)
echo "Test Status: $STATUS. Waiting for completion..."
;;
esac
sleep 10
done
3. Jenkins
To use the example below as is, reliv-api-key must be registered in Jenkins credentials.
You can change the env to whatever environment you wish to use.
Additionally, to prevent it from running indefinitely due to unforeseen reasons, a timeout of 10 minutes has been set. You can adjust this as needed.
pipeline {
environment {
RELIV_API_KEY = credentials('reliv-api-key') // Use Jenkins credentials
}
stages {
stage('Trigger Reliv Tests') {
steps {
script {
def response = sh(
script: "curl -s -X POST 'https://api.reliv.ai/api/v0/test-run-sets' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ${env.RELIV_API_KEY}' \
-d '{\"env\": \"default\"}'",
returnStdout: true
).trim()
def responseJson = readJSON text: response
env.TEST_RUN_SET_ID = responseJson.testRunSetId
}
}
}
stage('Check Reliv E2E Test Status') {
steps {
script {
timeout(time: 10, unit: 'MINUTES') {
while (true) {
def response = sh(
script: "curl -s -X GET 'https://api.reliv.ai/api/v0/test-run-sets/${env.TEST_RUN_SET_ID}' \
-H 'Authorization: Bearer ${env.RELIV_API_KEY}'",
returnStdout: true
).trim()
def responseJson = readJSON text: response
if (responseJson.status == 'SUCCESS') {
echo 'Test Status: SUCCESS'
break
} else if (responseJson.status == 'FAIL') {
error('Test Status: FAIL')
} else {
echo "Test Status: ${responseJson.status}. Waiting for completion..."
sleep time: 10, unit: 'SECONDS'
}
}
}
}
}
}
}
}