CI/CD Integration: Automate Testing in Your Development Pipelines
Last updated
Last updated
These instructions detail how to integrate Ratl into your CI/CD pipeline using public APIs across Jenkins, GitHub Actions, Azure DevOps (ADO) Pipelines, and GitLab. Each setup guide below provides steps for starting load, API, e2e, and web automation tests, fetching reports, and checking test statuses.
API Key :
Go to Organisation > API Keys.
Click Create API Key.
Copy the generated API key for use in the CI/CD pipeline.
IDs:
Simply navigate to the listing page of the specific tests, where you can copy the required IDs directly.
pipeline {
agent any
stages {
stage('Start Load Test') {
steps {
script {
sh 'curl -X POST https://api.studio.ratl.ai/public/api/v1/load/start \
-H "api-key: <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d \'{"simulation_id": "<SIMULATION_ID>", "project_id": "<PROJECT_ID>"}\''
}
}
}
stage('Check Load Test Status') {
steps {
script {
sh '''
STATUS="running"
while [ "$STATUS" == "running" ]; do
STATUS=$(curl -s -X GET https://api.studio.ratl.ai/public/api/v1/load/status \
-H "api-key: <YOUR_API_KEY>" \
-G --data-urlencode "simulation_id=<SIMULATION_ID>" | jq -r .status)
echo "Current status: $STATUS"
sleep 10
done
'''
}
}
}
stage('Get Load Test Report') {
steps {
script {
sh 'curl -X GET https://api.studio.ratl.ai/public/api/v1/load/report \
-H "api-key: <YOUR_API_KEY>" \
-G --data-urlencode "simulation_id=<SIMULATION_ID>"'
}
}
}
}
}
pipeline {
agent any
stages {
stage('Start API Test') {
steps {
script {
sh '''
curl -X POST "https://api.studio.ratl.ai/public/api/v1/api/start" \
-H "api-key: <YOUR_API_KEY>" \
-G --data-urlencode "suite_id=<SUITE_ID>"
'''
}
}
}
stage('Get API Test Report') {
steps {
script {
sh '''
curl -X POST "https://api.studio.ratl.ai/public/api/v1/api/report" \
-H "api-key: <YOUR_API_KEY>" \
-G --data-urlencode "suite_id=<SUITE_ID>"
'''
}
}
}
}
}
pipeline {
agent any
stages {
stage('Start E2E Test') {
steps {
script {
sh '''
curl -X POST "https://api.studio.ratl.ai/public/api/v1/e2e/start" \
-H "api-key: <YOUR_API_KEY>" \
-G --data-urlencode "flow_id=<FLOW_ID>"
'''
}
}
}
stage('Get E2E Test Report') {
steps {
script {
sh '''
curl -X POST "https://api.studio.ratl.ai/public/api/v1/e2e/report" \
-H "api-key: <YOUR_API_KEY>" \
-G --data-urlencode "flow_id=<FLOW_ID>"
'''
}
}
}
}
}
pipeline {
agent any
stages {
stage('Start Web Automation') {
steps {
script {
sh '''
curl -X POST https://api.studio.ratl.ai/public/api/v1/webshot/start \
-H "api-key: <YOUR_API_KEY>)" \
-G --data-urlencode "webshot_id=<WEBSHOT_ID>"
'''
}
}
}
stage('Get Web Automation Versions') {
steps {
script {
sh '''
curl -X GET "https://api.studio.ratl.ai/public/api/v1/webshot/report?task_id=<TASK_ID>" \
-H "api-key: <YOUR_API_KEY>"
'''
}
}
}
}
}
trigger:
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- script: |
curl -X POST https://api.studio.ratl.ai/public/api/v1/load/start \
-H "api-key: $(YOUR_API_KEY)" \
-H "Content-Type: application/json" \
-d '{"simulation_id": "<SIMULATION_ID>", "project_id": "<PROJECT_ID>"}'
displayName: 'Start Load Test'
- script: |
STATUS="running"
while [ "$STATUS" == "running" ]; do
STATUS=$(curl -s -X GET https://api.studio.ratl.ai/public/api/v1/load/status \
-H "api-key: $(YOUR_API_KEY)" \
-G --data-urlencode "simulation_id=<SIMULATION_ID>" | jq -r .status)
echo "Current status: $STATUS"
sleep 10
done
displayName: 'Check Load Test Status'
- script: |
curl -X GET https://api.studio.ratl.ai/public/api/v1/load/report \
-H "api-key: $(YOUR_API_KEY)" \
-G --data-urlencode "simulation_id=<SIMULATION_ID>"
displayName: 'Get Load Test Report'
trigger:
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- script: |
curl -X POST https://api.studio.ratl.ai/public/api/v1/api/start \
-H "api-key: $(YOUR_API_KEY)" \
-G --data-urlencode "suite_id=<SUITE_ID>"
displayName: 'Start API Test'
- script: |
mkdir -p $(Build.ArtifactStagingDirectory)/reports
curl -X POST https://api.studio.ratl.ai/public/api/v1/api/report \
-H "api-key: $(YOUR_API_KEY)" \
-G --data-urlencode "suite_id=<SUITE_ID>"
-o $(Build.ArtifactStagingDirectory)/reports/report.pdf
displayName: 'Get API Test Report'
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)/reports'
artifactName: 'PDFReport'
publishLocation: 'Container'
trigger:
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- script: |
curl -X POST https://api.studio.ratl.ai/public/api/v1/e2e/start \
-H "api-key: $(YOUR_API_KEY)" \
-G --data-urlencode "flow_id=<FLOW_ID>"
displayName: 'Start E2E Test'
- script: |
curl -X POST https://api.studio.ratl.ai/public/api/v1/e2e/report \
-H "api-key: $(YOUR_API_KEY)" \
-G --data-urlencode "flow_id=<FLOW_ID>"
displayName: 'Get E2E Test Report'
trigger:
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- script: |
curl -X POST https://api.studio.ratl.ai/public/api/v1/webshot/start \
-H "api-key: $(YOUR_API_KEY)" \
-G --data-urlencode "webshot_id=<WEBSHOT_ID>"
displayName: 'Start Web Automation'
- script: |
curl -X GET "https://api.studio.ratl.ai/public/api/v1/webshot/report?task_id=<TASK_ID>" \
-H "api-key: $(YOUR_API_KEY)"
displayName: 'Get Web Automation Report'
name: Load Test
on:
workflow_dispatch:
jobs:
load-test:
runs-on: ubuntu-latest
steps:
- name: Start Load Test
run: |
curl -X POST https://api.studio.ratl.ai/public/api/v1/load/start \
-H "api-key: ${{ secrets.YOUR_API_KEY }}" \
-H "Content-Type: application/json" \
-d '{"simulation_id": "<SIMULATION_ID>", "project_id": "<PROJECT_ID>"}'
- name: Check Load Test Status
run: |
STATUS="running"
while [ "$STATUS" == "running" ]; do
STATUS=$(curl -s -X GET https://api.studio.ratl.ai/public/api/v1/load/status \
-H "api-key: ${{ secrets.YOUR_API_KEY }}" \
-G --data-urlencode "simulation_id=<SIMULATION_ID>" | jq -r .status)
echo "Current status: $STATUS"
sleep 10
done
- name: Get Load Test Report
run: |
curl -X GET https://api.studio.ratl.ai/public/api/v1/load/report \
-H "api-key: ${{ secrets.YOUR_API_KEY }}" \
-G --data-urlencode "simulation_id=<SIMULATION_ID>"
name: API Test
on:
workflow_dispatch:
jobs:
api-test:
runs-on: ubuntu-latest
steps:
- name: Start API Test
run: |
curl -X POST https://api.studio.ratl.ai/public/api/v1/api/start \
-H "api-key: ${{ secrets.YOUR_API_KEY }}" \
-G --data-urlencode "suite_id=<SUITE_ID>"
- name: Get API Test Report
run: |
curl -X POST https://api.studio.ratl.ai/public/api/v1/api/report \
-H "api-key: ${{ secrets.YOUR_API_KEY }}" \
-G --data-urlencode "suite_id=<SUITE_ID>"
name: E2E Test
on:
workflow_dispatch:
jobs:
e2e-test:
runs-on: ubuntu-latest
steps:
- name: Start E2E Test
run: |
curl -X POST https://api.studio.ratl.ai/public/api/v1/e2e/start \
-H "api-key: ${{ secrets.YOUR_API_KEY }}" \
-G --data-urlencode "flow_id=<FLOW_ID>"
- name: Get E2E Test Report
run: |
curl -X POST https://api.studio.ratl.ai/public/api/v1/e2e/report \
-H "api-key: ${{ secrets.YOUR_API_KEY }}" \
-G --data-urlencode "flow_id=<FLOW_ID>"
name: Web Automation Test
on:
workflow_dispatch:
jobs:
webAutomation-test:
runs-on: ubuntu-latest
steps:
- name: Start Web Automation Review
run: |
curl -X POST https://api.studio.ratl.ai/public/api/v1/webshot/start \
-H "api-key: ${{ secrets.YOUR_API_KEY }}" \
-G --data-urlencode "webshot_id=<WEBSHOT_ID>"
- name: Get Web Automation Versions
run: |
curl -X GET "https://api.studio.ratl.ai/public/api/v1/webshot/report?task_id=<TASK_ID>" \
-H "api-key: ${{ secrets.YOUR_API_KEY }}"
stages:
- load_test_run
- load_test_report
variables:
YOUR_API_KEY: $YOUR_API_KEY
load_test_run:
stage: load_test_run
script:
- curl -X POST https://api.studio.ratl.ai/public/api/v1/load/start \
-H "api-key: $YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"simulation_id": "<SIMULATION_ID>", "project_id": "<PROJECT_ID>"}'
- STATUS="running"
- while [ "$STATUS" == "running" ]; do
STATUS=$(curl -s -X GET https://api.studio.ratl.ai/public/api/v1/load/status \
-H "api-key: $YOUR_API_KEY" \
-G --data-urlencode "simulation_id=<SIMULATION_ID>" | jq -r .status);
echo "Current status: $STATUS";
sleep 10;
done
load_test_report:
stage: load_test_report
script:
- curl -X GET https://api.studio.ratl.ai/public/api/v1/load/report \
-H "api-key: $YOUR_API_KEY" \
-G --data-urlencode "simulation_id=<SIMULATION_ID>"
stages:
- api_test_run
- api_test_report
variables:
YOUR_API_KEY: $YOUR_API_KEY
api_test_run:
stage: api_test_run
script:
- curl -X POST https://api.studio.ratl.ai/public/api/v1/api/start \
-H "api-key: $YOUR_API_KEY" \
-G --data-urlencode "suite_id=<SUITE_ID>"
api_test_report:
stage: api_test_report
script:
- curl -X POST https://api.studio.ratl.ai/public/api/v1/api/report \
-H "api-key: $YOUR_API_KEY" \
-G --data-urlencode "suite_id=<SUITE_ID>"
stages:
- e2e_test_run
- e2e_test_report
variables:
YOUR_API_KEY: $YOUR_API_KEY
e2e_test_run:
stage: e2e_test_run
script:
- curl -X POST https://api.studio.ratl.ai/public/api/v1/e2e/start \
-H "api-key: $YOUR_API_KEY" \
-G --data-urlencode "flow_id=<FLOW_ID>"
e2e_test_report:
stage: e2e_test_report
script:
- curl -X POST https://api.studio.ratl.ai/public/api/v1/e2e/report \
-H "api-key: $YOUR_API_KEY" \
-G --data-urlencode "flow_id=<FLOW_ID>"
stages:
- webshot_test_run
- webshot_test_report
variables:
YOUR_API_KEY: $YOUR_API_KEY
webshot_test_run:
stage: webshot_test_run
script:
- curl -X POST https://api.studio.ratl.ai/public/api/v1/webshot/start \
-H "api-key: $YOUR_API_KEY" \
-G --data-urlencode "webshot_id=<WEBSHOT_ID>"
webshot_test_report:
stage: webshot_test_report
script:
- curl -X GET "https://api.studio.ratl.ai/public/api/v1/webshot/report?task_id=<TASK_ID>" \
-H "api-key: $YOUR_API_KEY"
Insert API Key: Replace <YOUR_API_KEY>
with your actual API key in all scripts.
Simulation ID and Project ID: For load tests, replace <SIMULATION_ID>
and <WORKSPACE_ID>
with the appropriate values.
Suite ID: For API tests, replace <SUITE_ID>
with the appropriate value.
Flow ID: For E2E tests, replace <FLOW_ID>
with the appropriate value.
Status Check: For load tests, the script checks the status every 10 seconds and proceeds once the status is no longer "running".
Execution:
Load Tests: Run the pipeline to start the load test, check its status, and fetch the report.
API Tests: Run the pipeline to start the API test and fetch its report.
E2E Tests: Run the pipeline to start the E2E test and fetch its report.
Web Automation Tests: Run the pipeline to start the web automation tests.
Note: These scripts use
jq
to parse JSON responses, so ensurejq
is installed on the agents. Adjust the sleep duration as needed based on your test's expected duration.