Katalon TestCloud Jenkins Pipeline Script Example

I could not locate a Katalon TestCloud Jenkins example on the documentation.

Our organization preference is to version control the build configuration in pipeline scripts.
I have only managed to execute tests using a Freestyle project or calling the Freestyle project from another Pipeline job.

It is an issue using parameters and having to call a single Build Job from a series of Freestyle projects from a Pipeline depending on those passed in parameter values.

Is there a Jenkins Pipeline script example of the build process?

1 Like

Yes, there is a Jenkins Pipeline script example for executing Katalon tests with TestCloud environment. You can find it in the documentation (Execute Katalon tests on Jenkins with TestCloud environment | Katalon Docs). Here’s a script template for Windows:

pipeline {  
 agent any  
 stages {  
 stage('Test') {  
 steps {  
 bat """  
 cd <KRE installed folder>  
 katalonc -projectPath="<projectpath>" -browserType="TestCloud" -testcloudEnvironmentId="<string value>" -testcloudTunnel="<true or false>" -retry=<number of retry times> -statusDelay=<seconds> -testSuitePath="<path>" -apiKey="<user API key>" -orgID=<Katalon_OrgID>  
 """  
 }  
 }  
 }  
}

And here’s a script template for macOS/Linux:

pipeline {  
 agent any  
 stages {  
 stage('Test') {  
 steps {  
 sh '''  
 cd <KRE installed folder>  
 ./katalonc -projectPath="<projectpath>" -browserType="TestCloud" -testcloudEnvironmentId="<string value>" -testcloudTunnel="<true or false>" -retry=<number of retry time> -statusDelay=<seconds> -testSuitePath="<path>" -apiKey="<user API key>" -orgID=<Katalon_OrgID>  
 '''  
 }  
 }  
 }  
}

Make sure to replace the placeholders with your actual values, such as the Katalon Runtime Engine (KRE) installed folder, project path, test suite path, TestCloud environment ID, and API key.

Please let me know if this works for you.

@vu.tran I was hoping there was an API request solution that did not rely on installing the Katalon Runtime Engine.
Considering that the main purpose of TestCloud would be directly remote execute tests on a cloud platform rather than accessing a local resource then remotely connecting to TestCloud.

 cd <KRE installed folder> 

Just having to install and maintain another piece of technology in the build process creates another level of instrumentation that could easily be removed if there was a TestCloud API that could be accessed using some form of authentication, e.g. JWT or Bearer Token.

I agree that this is a solution, but it does not seem ideal from a DevOps perspective.

Thank you for your feedback, let me check again with our product team

let me check again with our product team

@vu.tran What was the outcome?

@jason.tolotta Instead of downloading the Katalon Runtime Engine, you just need to input the KRE version then KRE will be downloaded and deployed automatically. The KRE is used to run your test in the cloud environment. In this case, only TestCloud license is required, you don’t need to have an active KRE license.
The second way you can try is Execute a Katalon TestOps plan on Jenkins

1 Like

@ha.tpham EDIT: I created a new topic: Katalon Jenkins / TestCloud - Unable to Execute TestCloud Using Jenkins Plugin

I just tried the instructions described in the Execute a Katalon TestOps Plan on Jenkins guide and the Job failed.

I have the following questions:

  • -testcloudEnvironmentId=“87” - What is it and do I need it for TestCloud?
  • Why do I get an error stating I have no TestCloud licenses? My organization has 3 x TestCloud Licenses

I get the following Jenkins console log error:

Building on the built-in node in workspace /opt/bitnami/jenkins/jenkins_home/workspace/TESTOPS
[2023-06-13T12:30:17.146] Katalon Studio package has been downloaded already.
[2023-06-13T12:30:17.146] Using Katalon Studio at /opt/bitnami/jenkins/jenkins_home/.katalon/8.6.5/Katalon_Studio_Engine_Linux_64-8.6.5
[2023-06-13T12:30:17.146] Making driver executables...
[2023-06-13T12:30:17.146] Drivers folder at: /opt/bitnami/jenkins/jenkins_home/.katalon/8.6.5/Katalon_Studio_Engine_Linux_64-8.6.5/configuration/resources/drivers
[2023-06-13T12:30:17.146] Set msedgedriver as executable !
[2023-06-13T12:30:17.146] Set geckodriver as executable !
[2023-06-13T12:30:17.146] Set chromedriver as executable !
[2023-06-13T12:30:17.147] Execute [sh, -c, /opt/bitnami/jenkins/jenkins_home/.katalon/8.6.5/Katalon_Studio_Engine_Linux_64-8.6.5/katalonc -noSplash  -runMode=console  -projectPath=/tmp/project -retry=0 -statusDelay=15 -testSuitePath="Path/to/Test Suites" -browserType="TestCloud" -testcloudTunnel="false" -apikey=<secret-api-key> ] in /tmp/katalon-7722351561481957628
[2023-06-13T12:30:19.937] Katalon workspace folder is set to default location: /tmp/session-65fdedfe
[2023-06-13T12:30:20.194] Starting Groovy-Eclipse compiler resolver. Specified compiler level: unspecified
[2023-06-13T12:30:20.195] 138 org.codehaus.groovy_2.4.20.v202009301404-e2006-RELEASE ACTIVE
[2023-06-13T12:30:20.780] Activating...
[2023-06-13T12:30:20.787] Start getting machine ID on Linux
[2023-06-13T12:30:20.828] End getting machine ID on Linux 348d44d16b7a479be8be69e02ad87fefe
[2023-06-13T12:30:20.828] Start appending additional signatures
[2023-06-13T12:30:20.830] hardwareSerialNumber 
[2023-06-13T12:30:20.831] osDependentUsername jenkins
[2023-06-13T12:30:20.831] End appending additional signatures 348d44d16b7a479be8be69e02ad87fefe__jenkins
[2023-06-13T12:30:20.839] Start activating offline...
[2023-06-13T12:30:20.841] Search for valid offline licenses in folder: /opt/bitnami/jenkins/jenkins_home/.katalon/license
[2023-06-13T12:30:20.849] The number of valid offline licenses: 0
[2023-06-13T12:30:22.245] Start activating online...
[2023-06-13T12:30:27.280] Activated successfully with Katalon Runtime Engine license. 
[2023-06-13T12:30:27.281] Failed to activate with TestCloud license. null
[2023-06-13T12:30:27.295] Cannot execute this test suite. There is no TestCloud license available.
[2023-06-13T12:30:27.297] All launchers terminated
[2023-06-13T12:30:27.527] Finished executing sh -c /opt/bitnami/jenkins/jenkins_home/.katalon/8.6.5/Katalon_Studio_Engine_Linux_64-8.6.5/katalonc -noSplash  -runMode=console  -projectPath=/tmp/project -retry=0 -statusDelay=15 -testSuitePath="Path/to/Test Suites" -browserType="TestCloud" -testcloudTunnel="false" -apikey=<secret-api-key> . Exit code: 3.
Build step 'Execute Katalon Studio Tests' marked build as failure