Reputation: 914
For now I have a config.properties
file and a singleton configuration object, which reads the file to a map and then puts all the system variables there as well. So when I run my tests via Jenkins, job's parameters with the same name will override values, set in config.properties
file.
This is expected and correct behavior for me.
But I'd like to keep all the configuration and build parameters in GebConfig.groovy
file.
So two questions here:
Now, if I need to get GebConfig property in my code, I use browser.getConfig().getRawConfig().get("contextPath")
. Is it proper call or there is better way to get params from config in tests' code?
How to implement passing Jenkins job's parameters to Geb configuration?
I got only the idea to search for it in System.getenv()
first:
public String getProperty(String name) {
Map<String, String> systemEnv = System.getenv();
return systemEnv.get(name) ?: browser.config.rawConfig.get(name);
}
Upvotes: 0
Views: 1052
Reputation: 332
All build tools accept -DvarName=varValue to pass properties into GebConfig. Gradle, Maven, and Ant. So you'd pass that variable through in your Jenkins Build step
Edit: Below is in my GebConfig which handles default values vs passed in variables
System.setProperty("geb.env.username", System.getProperty("geb.env.username", 'test'))
Upvotes: 1