Search code examples
scalamavengatling

Setting environment variable in gatling scala maven is not working from terminal


I am trying to read some of the values from environment variables for my gatling project. But when I execute maven command, environment values are not set. It is displaying null.

I tried

`mvn gatling:test -Dgatling.simulationClass=dev.RandomVinAndVehIdentifierGenerator -Dargline=env=dev.

I even created a bash file and then gave for a run but I am always getting below error.

No configuration setting found for key 'null'

I am reading the environment value using below code.

 val env = System.getenv("env")
  var url =  ConfigFactory.load().getString(env + ".hostURL") 

env is always set null


Solution

  • It isn't an environment variables, it's a property. You should use this:

    System.getProperty("env")
    

    for

    mvn gatling:test -Denv=dev