# Jenkins

# Pre-requisites

  1. Ensure that Docker is installed on the Jenkins server.
  2. Install Docker plugin for Jenkins from the plugin store.

# Setup Instructions

  1. Create a new Jenkins Pipeline or open an existing one.

  2. Identify the stage where you want to add KushoAI or create a new stage if needed.

  3. Insert this snippet for running tests using KushoAI:

pipeline {
    agent any

    stages {
        stage('Pull Docker Image') {
            steps {
                script {
                    // Pull the Docker image from Docker Hub
                    sh 'docker pull public.ecr.aws/y5g4u6y7/kusho-jenkins-runner:latest'
                }
            }
        }

        stage('Run Docker Container') {
            steps {
                script {
                    // Run the Docker container and execute the script
                    sh 'docker run --rm -e TEST_SUITE_UUID="<TEST_SUITE_UUIDS>" -e ENVIRONMENT_ID="<ENV_ID>" -e API_KEY="<YOUR_API_KEY>" -e EMAIL="<COMMA_SEPARATED_EMAILS>" public.ecr.aws/y5g4u6y7/kusho-jenkins-runner:latest'
                }
            }
        }
    }
}
  1. Add your API Key to the snippet

    • Navigate to Manage Workspace -> API Keys
    • Click on "Create API Key"
    • Copy API Key and paste it under "API_KEY" arg in the "Run Docker Container" stage of the snippet
  2. Add your Test Suite UUIDs to the snippet

    • Navigate to Test Suites
    • Click on the menu icon for a test suite (rightmost button in the row, three vertical dots) and click on "Copy UUID"
    • Paste this UUID under "TEST_SUITE_ID" arg in the "Run Docker Container" stage of the snippet. Note that you can paste multiple comma-separated UUIDs to run multiple test suites.
  3. Add comma-separated emails to receive the test report

    • Update the EMAIL variable in the script to include the email addresses where you want the report sent.
    • For multiple emails, simply add them in a comma-separated format, e.g. "email1@example.com,email2@example.com".
    • This is optional, and if you don't provide an email, the report won't be sent via email.