> For the complete documentation index, see [llms.txt](https://docs.ratl.ai/guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ratl.ai/guide/integrations/cicd-1.md).

# CI/CD Integration: Automate Testing in Your Development Pipelines

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.&#x20;

### Prerequisites

1. **API Key** [**(refer the guide here)**](/guide/manage-account/api-keys.md)**:**
   * Go to Settings > API Keys.
   * Click Create API Key.
   * Copy the generated API key for use in the CI/CD pipeline.
2. **IDs:**
   * Simply navigate to the listing page of the specific tests, where you can copy the required IDs directly.

### Jenkins Integration

#### Web Test

```yaml
pipeline {
    agent any

    stages {
        // Case 1: Base URL
        stage('Start Web Automation - Base URL') {
            steps {
                script {
                    sh '''
                    curl --location 'https://api.studio.ratl.ai/public/api/v1/webshot/start' \
                    --header 'Content-Type: application/json' \
                    --header 'api-key: <YOUR_API_KEY>' \
                    --data '{
                        "workspace_id":"<WORKSPACE_ID>",
                        "base_url": "<BASE_URL>",
                        "channel_id": "<CHANNEL_ID>"
                    }'
                    '''
                }
            }
        }

        // Case 2: Single webshot_id
        stage('Start Web Automation - Single ID') {
            steps {
                script {
                    sh '''
                    curl --location 'https://api.studio.ratl.ai/public/api/v1/webshot/start' \
                    --header 'Content-Type: application/json' \
                    --header 'api-key: <YOUR_API_KEY>' \
                    --data '{
                        "webshot_id": "<WEBSHOT_ID>",
                        "workspace_id":"<WORKSPACE_ID>",
                        "channel_id": "<CHANNEL_ID>"
                    }'
                    '''
                }
            }
        }

        // Case 3: Multiple webshot_ids
        stage('Start Web Automation - Multiple IDs') {
            steps {
                script {
                    sh '''
                    curl --location 'https://api.studio.ratl.ai/public/api/v1/webshot/start' \
                    --header 'Content-Type: application/json' \
                    --header 'api-key: <YOUR_API_KEY>' \
                    --data '{
                        "workspace_id":"<WORKSPACE_ID>",
                        "webshot_ids":["<WEBSHOT_ID_1>", "<WEBSHOT_ID_2>"],
                        "channel_id": "<CHANNEL_ID>"
                    }'
                    '''
                }
            }
        }

        // Case 4: All webshots in workspace
        stage('Start Web Automation - Workspace All') {
            steps {
                script {
                    sh '''
                    curl --location 'https://api.studio.ratl.ai/public/api/v1/webshot/start' \
                    --header 'Content-Type: application/json' \
                    --header 'api-key: <YOUR_API_KEY>' \ 
                    --data '{
                        "workspace_id":"<WORKSPACE_ID>",
                        "channel_id": "<CHANNEL_ID>"
                    }'
                    '''
                }
            }
        }
    }
}
```

### Azure DevOps (ADO) Pipelines Integration

#### Web Test

```yaml
trigger:
  branches:
    include:
      - main

pool:
  vmImage: 'ubuntu-latest'

steps:
  # Case 1: Base URL
  - script: |
      curl --location 'https://api.studio.ratl.ai/public/api/v1/webshot/start' \
      --header 'Content-Type: application/json' \
      --header 'api-key: $(YOUR_API_KEY)' \
      --data '{
          "workspace_id":"<WORKSPACE_ID>",
          "base_url": "<BASE_URL>",
          "channel_id": "<CHANNEL_ID>"
      }'
    displayName: 'Start Web Automation (Base URL)'

  # Case 2: Single webshot_id
  - script: |
      curl --location 'https://api.studio.ratl.ai/public/api/v1/webshot/start' \
      --header 'Content-Type: application/json' \
      --header 'api-key: $(YOUR_API_KEY)' \
      --data '{
          "webshot_id": "<WEBSHOT_ID>",
          "workspace_id":"<WORKSPACE_ID>",
          "channel_id": "<CHANNEL_ID>"
      }'
    displayName: 'Start Web Automation (Single ID)'

  # Case 3: Multiple webshot_ids
  - script: |
      curl --location 'https://api.studio.ratl.ai/public/api/v1/webshot/start' \
      --header 'Content-Type: application/json' \
      --header 'api-key: $(YOUR_API_KEY)' \
      --data '{
          "workspace_id":"<WORKSPACE_ID>",
          "webshot_ids":["<WEBSHOT_ID_1>", "<WEBSHOT_ID_2>"],
          "channel_id": "<CHANNEL_ID>"
      }'
    displayName: 'Start Web Automation (Multiple IDs)'

  # Case 4: All webshots in workspace
  - script: |
      curl --location 'https://api.studio.ratl.ai/public/api/v1/webshot/start' \
      --header 'Content-Type: application/json' \
      --header 'api-key: $(YOUR_API_KEY)' \
      --data '{
          "workspace_id":"<WORKSPACE_ID>",
          "channel_id": "<CHANNEL_ID>"
      }'
    displayName: 'Start Web Automation (Workspace All)'
```

### GitHub Actions Integration

#### Web Test

```yaml
name: Web Automation Test

on:
  workflow_dispatch:

jobs:
  webAutomation-test:
    runs-on: ubuntu-latest

    steps:
      # Case 1: Base URL
      - name: Start Web Automation (Base URL)
        run: |
          curl --location 'https://api.studio.ratl.ai/public/api/v1/webshot/start' \
          --header 'Content-Type: application/json' \
          --header 'api-key: ${{ secrets.YOUR_API_KEY }}' \
          --data '{
              "workspace_id":"<WORKSPACE_ID>",
              "base_url": "<BASE_URL>",
              "channel_id": "<CHANNEL_ID>"
          }'

      # Case 2: Single webshot_id
      - name: Start Web Automation (Single ID)
        run: |
          curl --location 'https://api.studio.ratl.ai/public/api/v1/webshot/start' \
          --header 'Content-Type: application/json' \
          --header 'api-key: ${{ secrets.YOUR_API_KEY }}' \          
          --data '{
              "webshot_id": "<WEBSHOT_ID>",
              "workspace_id":"<WORKSPACE_ID>",
              "channel_id": "<CHANNEL_ID>"
          }'

      # Case 3: Multiple webshot_ids
      - name: Start Web Automation (Multiple IDs)
        run: |
          curl --location 'https://api.studio.ratl.ai/public/api/v1/webshot/start' \
          --header 'Content-Type: application/json' \
          --header 'api-key: ${{ secrets.YOUR_API_KEY }}' \
          --data '{
              "workspace_id":"<WORKSPACE_ID>",
              "webshot_ids":["<WEBSHOT_ID_1>", "<WEBSHOT_ID_2>"],
              "channel_id": "<CHANNEL_ID>"
          }'

      # Case 4: All webshots in workspace
      - name: Start Web Automation (Workspace All)
        run: |
          curl --location 'https://api.studio.ratl.ai/public/api/v1/webshot/start' \
          --header 'Content-Type: application/json' \
          --header 'api-key: ${{ secrets.YOUR_API_KEY }}' \
          --data '{
              "workspace_id":"<WORKSPACE_ID>",
              "channel_id": "<CHANNEL_ID>"
          }'
```

### GitLab CI/CD Integration

#### Web Test&#x20;

```yaml
stages:
  - webshot_test_run

variables:
  YOUR_API_KEY: $YOUR_API_KEY

# Case 1: Base URL
webshot_base_url:
  stage: webshot_test_run
  script:
    - curl --location 'https://api.studio.ratl.ai/public/api/v1/webshot/start' \
      --header 'Content-Type: application/json' \
      --header 'api-key: $YOUR_API_KEY' \
      --data '{
          "workspace_id":"<WORKSPACE_ID>",
          "base_url": "<BASE_URL>",
          "channel_id": "<CHANNEL_ID>"
      }'

# Case 2: Single webshot_id
webshot_single_id:
  stage: webshot_test_run
  script:
    - curl --location 'https://api.studio.ratl.ai/public/api/v1/webshot/start' \
      --header 'Content-Type: application/json' \
      --header 'api-key: $YOUR_API_KEY' \
      --data '{
          "webshot_id": "<WEBSHOT_ID>",
          "workspace_id":"<WORKSPACE_ID>",
          "channel_id": "<CHANNEL_ID>"
      }'

# Case 3: Multiple webshot_ids
webshot_multiple_ids:
  stage: webshot_test_run
  script:
    - curl --location 'https://api.studio.ratl.ai/public/api/v1/webshot/start' \
      --header 'Content-Type: application/json' \
      --header 'api-key: $YOUR_API_KEY' \
      --data '{
          "workspace_id":"<WORKSPACE_ID>",
          "webshot_ids":["<WEBSHOT_ID_1>", "<WEBSHOT_ID_2>"],
          "channel_id": "<CHANNEL_ID>"
      }'

# Case 4: All webshots in workspace
webshot_workspace_all:
  stage: webshot_test_run
  script:
    - curl --location 'https://api.studio.ratl.ai/public/api/v1/webshot/start' \
      --header 'Content-Type: application/json' \
      --header 'api-key: $YOUR_API_KEY' \
      --data '{
          "workspace_id":"<WORKSPACE_ID>",
          "channel_id": "<CHANNEL_ID>"
      }'
```

#### Instructions

* **Insert API Key:** Replace `<YOUR_API_KEY>` with your actual API key in all scripts.
* Replace `<WORKSPACE_ID>` , `<WEBSHOT_ID>` and `<CHANNEL_ID>` with appropriate values
* Run the pipeline to start the web automation tests.

> **Note:** These scripts use `jq` to parse JSON responses, so ensure `jq` is installed on the agents. Adjust the sleep duration as needed based on your test's expected duration.
