How to use environment Variables (jenkins => Maven Conflict?)

You can make it work using :

sys.env(“$USER”).toInt

Cheers,

Pierre

I’m not sure that env vars are propagated from Jenkins to Gatling.

Tnx both

class OpenScenario extends Simulation {

  val constantUsers : Double = java.lang.Double.valueOf(sys.env.getOrElse("constantUsers", "15.5"))
  val constantUsersDuration : Double = java.lang.Double.valueOf(sys.env.getOrElse("constantUsersDuration", "5.5")).toDouble
  val userAtOnce = Integer.getInteger("usersAtOnce", 1)

  val OpenScenario = scenario("OpenScenario_v0.1")
    .exec(
      *randomUser.get*
    )

  setUp(
    OpenScenario.inject(
      atOnceUsers(userAtOnce),
      nothingFor(1 seconds),
      constantUsersPerSec(constantUsers) during(constantUsersDuration minutes)
    )
  )
    .protocols(openProtocol)

}

The int works, but both doubles do not, must I use scala or java?

You can’t define a duration from a double, it must be an Int. Use seconds.

Thank you!

But… the constantUsersPerSec? There I must use a Double, right?

val constantUsersPerSec : Double = java.lang.Double.valueOf(sys.env.getOrElse("constantUsersDuration", "1")).toDouble

But this does not work? Is this because of syntax or am I looking in the wrong place?

Tnx

val constantUsers = sys.env.getOrElse(“constantUsers”, “15.5”).toDouble

val constantUsersDuration = sys.env.getOrElse(“constantUsersDuration”, “5.5”).toInt

val userAtOnce = Integer.getInteger(“usersAtOnce”, 1).toInt