The -executionProfile= approach requires the new settings are still managed by Katalon Studio. If you want to set a credential (username/password pair) in the Execution Profile, you will want to encrypt it. Katalon Studio does provide a encryption feature as described at https://docs.katalon.com/display/KD/Working+with+Sensitive+Text
However some people argue that the Katalon’s encryption is not strong enough:
I think that it would be best secure if you entirely exclude the credential information out of the Katalon’s project. My -Dkatalon.user.home= approach is meant for that.
It depends how much of security you require for the testing fixtures. I do not like a username/password pair in the testing fixture to be visible as plain text. But I would accept it if encrypted even though the Katalon’s encryption method is not superior. Because, in my case, the credentials in my testing fixture are not so much serious.
You can also define environment variable (with path to external configuration or properties file) in the session will be used to execute Katalon studio and then in the TestListener read the value of variable (path to the file), load that file and override settings for project, Global variables etc. To create new GlobalVariable I used metaprogramming:
void addGlobalVariable(String name, def value) {
MetaClass mc = script.evaluate("internal.GlobalVariable").metaClass
String getterName = "get" + name.capitalize()
mc.static."$getterName" = { -> return value }
//mc.static."$name" = value
}
It’s possible to add getter/setter as new methods to GlobalVariable class or add new field (commented in this example)
Than in the script code you can use GlobalVariable.VarName where the VarName you new variable.
You can also define environment variable (with path to external configuration or properties file) in the session will be used to execute Katalon studio and then in the TestListener read the value of variable (path to the file), load that file and override settings for project, Global variables etc. To create new GlobalVariable I used metaprogramming:
void addGlobalVariable(String name, def value) {
MetaClass mc = script.evaluate("internal.GlobalVariable").metaClass
String getterName = "get" + name.capitalize()
mc.static."$getterName" = { -> return value }
//mc.static."$name" = value
}
It's possible to add getter/setter as new methods to GlobalVariable class or add new field (commented in this example)
Than in the script code you can use GlobalVariable.VarName where the VarName you new variable.
What is the ‘script’ variable in your example? It would be nice if others can execute your script for their cases.
+1
I would love to be able to pass user defined parameters to the test suite through the command line. Currently, I am running a test suite through Jenkins, and I would like to take advantage of parameterizing my Jenkins job so that my test suite can execute more accurately to my needs. I would use the parameters defined in my Jenkins job, and pass them into the batch command line for the test suite to use.
+1 Our CI-CD system spins up dynamically named environments, and URLs based on branch names. It isn’t possible to know what is and isn’t going to be built and preload all these options as profiles within the GUI. It is absolutely necessary to be able to provide a minimum set of variables at CLI execution.
The developer commits a feature branch to the repository.
Jenkins builds an EC2 instance, registers an ssl cert, and deploys the build.
the url is https://{{ branch_name }}-devui.windsorcircle.com
or
locally we frequently spin up multiple stacks to compare version1 to version2. As such the container names are generated dynamically
the url is https://{{ branch_name }}-devui.windsorcircle.com
I see you have 2 problems to solve.
Problem1 : you need to be informed of the branch_name which Jenkins checked out and started to build, but how?
Problem2 : you need to generate the url string which contains the value of the branch_name, and pass it to the test suites in Katalon Studio, but how?
As for Problem1, Jenkins creates OS Environment variable **GIT_BRANCH . **This env variable is accessible for shell scripts that invokes katalon.exe. See
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUIimport internal.GlobalVariable as GlobalVariableWebUI.comment(">>> GlobalVariable.URL is ${GlobalVariable.URL}")WebUI.openBrowser('')WebUI.navigateToUrl(GlobalVariable.URL)WebUI.delay(3)WebUI.closeBrowser()
try to avoid using the back-tick form. it is working (almost) well but:
- it is not POSIX compliant
- building more complex commands can give you serious headache if you do a mistake
The only issue I had was giving the relevant portion of the URL to Katalon.
Reading in a series of environment variables is a cumbersome but acceptable workaround.
your example includes testurl and url as names for the environment variable, guessing that was an accident.
yep +1 from me as well. Was asked to set up our Jenkins Automation pipeline so that it could run on any url for our various testing environments, and also so that it could be run with any account. But it seems like Katalon is limited to only predefined variables, which is disappointing.
Im able to setup my environment URLs and run tests in my dev environment, and in other environments via Jenkins (using the Parameterized Scheduler Plugin).