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, see this Jenkins documentation: Using a Jenkinsfile.

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

Important:
  • Jenkins installed. Follow the instructions in this Jenkins documentation: Installing Jenkins.

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

  • An active KRE license. To learn more about activating a KRE license, see Activate licenses.

Configure and execute a Jenkins Pipeline project

To set up and run your Jenkins Pipeline project, follow these steps:
  1. In the Jenkins Dashboard, go to New Item and create a Pipeline project.
  2. In the Definition dropdown list, choose 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:

    You can find more command-line options at Command syntax.

  4. After the configuration, select Save, then select Build Now to run the project.
    Build your Jenkins project

  5. To view the console log, click on your current build on Jenkins and choose 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>
Was this page helpful?