Configure gatling parameters from Jenkins

Hi everybody,

I am working with Gatling and I installed it in Jenkins.
It works good but i would like to configure my values from Jenkins.

How can i do it ?

Thanks a lot !

Hi,

Which parameters do you want to override?

The ones from gatling.conf, or ones to be directly used within your Simulation class?
For both, the best way is with System properties.

Regarding gatling.conf, let’s say you have something like

foo {
bar: baz
}

and you want override bar value, you’d set -Dfoo.bar=qix

Regarding values within the Simulation class, such as number of users, just like in Java: https://github.com/excilys/gatling/wiki/Passing-parameters
Beware that Scala has its own Int type different from Integer, so if the compiler complains it gets an Integer when expecting an Int, just converte your Integer with .toInt

Cheers,

Stéphane

Hi Stéphane,

I would like to control all parameters in my scenarios.
For example, the number of users and the baseUrl for the simulation, the feeder file, the link for the queries etc…

Simply, i don’t want to touch the code anymore.

Thank you !!

Then you’ll have to define a System property for every parameter you want to be able to set.
Good luck.

How do you use it ?

Thanks

I sent you a wiki link in my first answer.

Thanks !

But i have errors. I configured the Global Properties in Jenkins and add an environment variable:

JAVA_OPTS
“-Dusers=3”

And my simulation :

val nbUsersString = System.getProperty(“users”)
val nbUsers = Integer.parseInt(nbUsersString)

Here the errors:

Simulation com.intuiko.training.gatling.simulations.IntuikoSimulation started...
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at scala_maven_executions.MainHelper.runMain(MainHelper.java:164)
	at scala_maven_executions.MainWithArgsInFile.main(MainWithArgsInFile.java:26)
Caused by: java.lang.NumberFormatException: null
	at java.lang.Integer.parseInt(Integer.java:417)
	at java.lang.Integer.parseInt(Integer.java:499)
	at com.intuiko.training.gatling.simulations.IntuikoSimulation.<init>(IntuikoSimulation.scala:12)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at java.lang.Class.newInstance0(Class.java:355)
	at java.lang.Class.newInstance(Class.java:308)
	at com.excilys.ebi.gatling.core.runner.Runner.run(Runner.scala:43)
	at com.excilys.ebi.gatling.app.Gatling$$anonfun$15.apply(Gatling.scala:102)
	at com.excilys.ebi.gatling.app.Gatling$$anonfun$15.apply(Gatling.scala:94)
	at scala.Option.getOrElse(Option.scala:108)
	at com.excilys.ebi.gatling.app.Gatling.start(Gatling.scala:94)
	at com.excilys.ebi.gatling.app.Gatling$.fromMap(Gatling.scala:54)
	at com.excilys.ebi.gatling.app.Gatling$.runGatling(Gatling.scala:74)
	at com.excilys.ebi.gatling.app.Gatling$.main(Gatling.scala:49)
	at com.excilys.ebi.gatling.app.Gatling.main(Gatling.scala)
	... 6 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.043s
[INFO] Finished at: Tue Oct 08 17:33:28 CEST 2013
[INFO] Final Memory: 7M/148M
[INFO] ------------------------------------------------------------------------
[JENKINS] Archiving /home/tomcat/.jenkins/jobs/TEST-gatling/workspace/gatling/pom.xml to /home/tomcat/.jenkins/jobs/TEST-gatling/modules/com.intuiko.training.gatling$test/builds/2013-10-08_17-33-03/archive/com.intuiko.training.gatling/test/0.0.1-SNAPSHOT/test-0.0.1-SNAPSHOT.pom
En attente que Jenkins finisse de récupérer les données
channel stopped
Archiving Gatling reports...
ERROR: Publisher com.excilys.ebi.gatling.jenkins.GatlingPublisher aborted due to exception
[java.lang.IllegalArgumentException](http://stacktrace.jenkins-ci.org/search?query=java.lang.IllegalArgumentException): Could not find a Gatling report in results folder.
	at [com.excilys.ebi.gatling.jenkins.GatlingPublisher.saveFullReports(GatlingPublisher.java:97)](http://stacktrace.jenkins-ci.org/search/?query=com.excilys.ebi.gatling.jenkins.GatlingPublisher.saveFullReports&entity=method)
	at [com.excilys.ebi.gatling.jenkins.GatlingPublisher.perform(GatlingPublisher.java:65)](http://stacktrace.jenkins-ci.org/search/?query=com.excilys.ebi.gatling.jenkins.GatlingPublisher.perform&entity=method)
	at [hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36)](http://stacktrace.jenkins-ci.org/search/?query=hudson.tasks.BuildStepMonitor$3.perform&entity=method)
	at [hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:814)](http://stacktrace.jenkins-ci.org/search/?query=hudson.model.AbstractBuild$AbstractBuildExecution.perform&entity=method)
	at [hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:786)](http://stacktrace.jenkins-ci.org/search/?query=hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps&entity=method)
	at [hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:947)](http://stacktrace.jenkins-ci.org/search/?query=hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2&entity=method)
	at [hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:733)](http://stacktrace.jenkins-ci.org/search/?query=hudson.model.AbstractBuild$AbstractBuildExecution.post&entity=method)
	at [hudson.model.Run.execute(Run.java:1592)](http://stacktrace.jenkins-ci.org/search/?query=hudson.model.Run.execute&entity=method)
	at [hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:477)](http://stacktrace.jenkins-ci.org/search/?query=hudson.maven.MavenModuleSetBuild.run&entity=method)
	at [hudson.model.ResourceController.execute(ResourceController.java:88)](http://stacktrace.jenkins-ci.org/search/?query=hudson.model.ResourceController.execute&entity=method)
	at [hudson.model.Executor.run(Executor.java:237)](http://stacktrace.jenkins-ci.org/search/?query=hudson.model.Executor.run&entity=method)
Finished: FAILURE

Thanks a lot !

My2cents: you configured your options for the JVM running Jenkins, not the one running the job.

Assuming you have a maven based job, you configured Build > Goals et options with something like “mvn clean”.
Add your -Dusers=3 there.

Also note that IMHO you’re doing something a bit ugly: setting up an int property, fetching it as a String, and converting it back again into an Int.
http://docs.oracle.com/javase/7/docs/api/java/lang/Integer.html#getInteger(java.lang.String)

You can even define default values.

Great !! It works !! Thank you !!

Great news!

Have fun