Skip to main content

Execute Katalon Studio tests with Jenkins Pipeline Script (Jenkinsfile)

Jenkins Pipeline (Jenkinsfile) provides an extensible set of tools for modeling simple-to-complex delivery pipelines. To learn more about creating a Jenkinsfile, you can refer to this Jenkins document: Using a Jenkinsfile.

Important:
  • Jenkins installed. Follow the instructions in this Jenkins document for installation: Getting started.

  • Katalon Runtime Engine (KRE) installed. You can download Katalon Runtime Engine here: Katalon products.

  • An active Katalon Runtime Engine license. To learn more about activating the Katalon Runtime Engine license, you can refer to this document: Activate Katalon License.

This tutorial shows you how to execute Katalon Studio tests in Jenkins with Jenkins Pipeline Script (Jenkinsfile). Follow these steps:

  1. In the Jenkins Dashboard, go to New Item and create a Jenkins Pipeline project.
  2. In the Definition dropdown list, select Pipeline Script.

    Select Pipeline script

  3. Copy and paste the following command-line arguments in the Script box:

    For Windows
    pipeline {
    agent any
    stages {
    stage('Test') {
    steps {
    bat """
    cd <KRE installed folder>
    katalonc -projectPath="<projectpath>" -browserType="<browser>" -retry=<number of retry times> -statusDelay=<seconds> -testSuitePath="<path>" -apiKey="<user API key>" -orgID=<Katalon_OrgID>
    """

    }

    }

    }

    }

    Windows Pipeline script

    For example:
    pipeline {
    agent any
    stages {
    stage('Test') {
    steps {
    bat """
    cd C:\Users\NAH\Desktop\Katalon_Studio_Engine_Windows_64-8.1.0
    katalonc -projectPath="C:\Users\NAH\Desktop\ci-samples-master\test.prj" -browserType="Chrome" -retry=0 -statusDelay=15 -testSuitePath="Test Suites/TS_RegressionTest" -apiKey="<user API key>" -orgID=<Katalon_OrgID>
    """

    }

    }

    }

    }
    For macOS/Linux
    pipeline {
    agent any
    stages {
    stage('Test') {
    steps {
    sh '''
    cd <KRE installed folder>
    ./katalonc -projectPath="<projectpath>" -browserType="<browse>" -retry=<number of retry time> -statusDelay=<seconds> -testSuitePath="<path>" -apiKey="<user API key>" -orgID=<Katalon_OrgID>
    '''

    }

    }

    }

    }

    Mac Pipeline script

    For example:
    pipeline {
    agent any
    stages {
    stage('Test') {
    steps {
    sh '''
    cd /Users/yen.nguyen/Downloads/Katalon_Studio_Engine_MacOS-8.1.0/Katalon\\ Studio\\ Engine.app/Contents/MacOS
    ./katalonc -projectPath="/Users/yen.nguyen/Downloads/ci-samples-master/test.prj" -browserType="Chrome" -retry=0 -statusDelay=15 -testSuitePath="Test Suites/TS_RegressionTest" -apiKey="<user API key>" -orgID=<Katalon_OrgID>
    '''

    }

    }

    }

    }
    Note:
  4. After the configuration, click Save, then click Build Now to run the project.

    Build your Jenkins project

  5. To view the console log, click on your current build on Jenkins and select Console Output.

    View console output

Troubleshooting: java.lang.NoClassDefFoundError: org/openqa/selenium/WebElement

When you run your test with Jenkins on Ubuntu using the Jenkins pipeline script (Jenkinsfile), you might encounter the error: "java.lang.NoClassDefFoundError: org/openqa/selenium/WebElement"

This error happens because Jenkins requires the read, write, and execute permissions to the Katalon Runtime Engine installed folder.

To resolve this error, add the read, write, and execute permissions to the Katalon Runtime Engine installed folder and rerun the Jenkins job. Run the following command:
sudo chmod -R 777 <path to the Katalon Runtime Engine installed folder>