System environment variables are not recognized by 'engine' when running tests

I have a macOS system environment variable, ‘dev’ set. Which is essentially the baseUrl

export dev="

in my test code, the baseUrl is set by it:

private HttpProtocolBuilder httpProtocol = http
        .inferHtmlResources(AllowList(), DenyList(".*\\.js", ".*\\.css", ".*\\.gif", ".*\\.jpeg", ".*\\.jpg", ".*\\.ico", ".*\\.woff", ".*\\.woff2", ".*\\.(t|o)tf", ".*\\.png", ".*detectportal\\.firefox\\.com.*"))
        .acceptEncodingHeader("gzip, deflate")

Further, I can run this from the command line, without error:
mvn gatling:test -gatling.simulationClass=customer.OccCustImpactApiLoadSimulation

Yet, when I use the recorder to run it. The failed test run indicates a reference to a completely different url. In the screenshot attachment, the url is showing up at ‘…'. Also, included is another screenshot showing the system envirionment variable, ‘dev’ is ‘https:int1-api.doterr…’?

How can I resolve this?

I don’t get what problem you have.

Geting system variable isn’t Gatling functionality, it’s standard Java thing.
I make a test and set variable:

Using Simulation:

public class Case0006CommandLineParametersSimulation extends Simulation {

    int foo = Integer.getInteger("foo", 1);
    String bar = System.getProperty("bar");

    HttpProtocolBuilder httpProtocol =

    ScenarioBuilder scn =
                                    .get("/get?foo=" + foo + "&bar=" + bar)


Run by Engine:


1 Like

Yet, when I use the recorder to run it.

The recorder is used to record, eg from your browser.
You probably mean the engine?

the url is showing up at ‘…

baseUrl is only a prefix used for all relative urls explicitly declared in your test.

Gatling could end up performing requests to other domains because:

  • you’ve also declared absolute urls in your test
  • Gatling is following redirects, eg when during some authentication process
  • Gatling is instructed to infer HTML resources declared in your HTML responses (which is something that you do, see inferHtmlResources )

Yes, the problem is the baseUrl , which is set as an environment variable is NOT the same URL showing when running by Engine:

  • List item in my screenshots, all show the baseUrl as ‘int1-api.doterra…’ except the Engine run, which shows it as ‘prf3.doterr…’

yes, it is the Engine run which shows a different Url used than the one specified as baseUrl. This can be seen by examining the screenshots included with post

So if you have uncommented line 23 everything is working for correct address?
What gatling version you use?
For additionally check create additional system variable and try to get value from it.
Delete target folder and check if this help.
As @slandelle mentioned there can be other things where this value is overwriten.
Show us place where you make this httpRequest.

Do you ensure that IntelliJ add such environment variables when running it?

See Add environment variables and program arguments


Excellent suggestion, many thanks!

The http request source code of the http request is in screenshot provided. Deleting target and running was tried. It turned out to be that the IntelliJ environment variable was set to something other than the code. Thanks