pass command line argument to simulation telling it which scenario to run

Hi guys, I’m looking for a way to pass the scenario name I want to run in simulation via the command line./

For example:
The command line command and arguments look like this:

mvn gatling:test -DUSERS=10 -DRAMP_DURATION=100 -DDURATION=2400 -DTESTNAME=“scnCreateUser”

I am running this in Jenkins and I want to be able to configure the scenario to run from there and not have to hard code it

these are my different files:

request file(MSXPlatformUser.scala)

package ...

import ...

object MSXPlatformUser extends BaseSimulation{

  def randomString(length: Int):String = {

  def getPagedTenants: ChainBuilder = {
      .exec(http("Get Existing Tenants Paged")


  def createNewUser: ChainBuilder = {
      .exec(http("Create New User")

  def getNewUser: ChainBuilder = {
    exec(http("Retrieve New User")

Scenario File (Scenario.scala)

I tried this once:!msg/gatling/Xer3yokbINQ/BqhUyBipc7oJ

Thank you Vu! I got it to work well partly. And it works very well! Next I want to pass an argument with a list. For example -Dtestsimulationstorun=test5,test25,test7. Any idea if this is possible?

-George K

I’m glad you made it work.

Below is the gist of what I have currently. You may want to add more Scala codes for your specific need. Hope that helps!


class Test extends Simulation {

def getOption(key: String, default: String): String = { java.lang.System.getProperty(key, default) }

val simScenarios = getOption(…) /** this is your testsimulationstorun /
val simUrls = getOption(…) /
* this is your target server urls */

def testSimulation = {

val testScenarios = Map(

“test1” → Set(
“test2” → Set(
“test3” → Set(

.foldLeftSet[io.gatling.core.structure.PopulationBuilder]((sim, scn) => sim ++ testScenarios(scn.trim()))

def testProtocol = {

val testBaseUrls: Vector[String] = simUrls.split(",|\+").map(_.trim()).toVector

val testHeaders: Map[String, String] = Map(
“Connection” → “close”

.baseURLs(testBaseUrls: _*)

setUp(testSimulation: _*).protocols(testProtocol)