Home > Back-end >  Setting environment variable in gatling scala maven is not working from terminal
Setting environment variable in gatling scala maven is not working from terminal

Time:01-19

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

CodePudding user response:

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

System.getProperty("env")

for

mvn gatling:test -Denv=dev
  •  Tags:  
  • Related