Env variable as command line arguments.

708 views
Skip to first unread message

Sreejith Edayillam

unread,
Apr 3, 2017, 9:00:28 AM4/3/17
to getgauge
Hi,

I gone through the Gauge document and found some useful information about how to run the project in different development enviroment. Basically its asking to set up a env folder for each environment we are using.

In our case, we have around 50 dev boxes which has different domain name (url will be diffirent, eg: www.devbox1.<xxx>.com, www.devbox2.<xxx>.com) so i have to create that many folders inside env folder.

Is there any option where i can pass the devbox url and browser as an argument from command line?


Thank You,
Sreejith.

Srikanth V

unread,
Apr 3, 2017, 11:55:07 AM4/3/17
to getgauge
Hi,

All gauge configuration that resides in the .properties files can be overridden by setting the respective environment variable.

In your case, you may set the url value per run via environment variable. Please refer here to understand the precedence of env variables.

HTH
Srikanth

Sreejith Edayillam

unread,
Apr 3, 2017, 11:56:42 PM4/3/17
to getgauge
Hi Srikanth,

I got that point but in my case, i have to create around 50+ env variable as we are running the tests from Jenkins.

Is there any way i can pass it as a parameter with mvn gauge:execute command.

Thank You,
Sreejith.

Srikanth V

unread,
Apr 4, 2017, 12:07:26 AM4/4/17
to getgauge
Hi,

Apologies if I misunderstood your initial query.

As I understand it, you would like to set some environment variables for a run (you say > 50 env vars).

Gauge does not takes all environment variables via command line flags. So, if I have to set it via command line I would do something like this:

VAR1=val1 VAR2=val2 gauge specs

Thus I am able to pass Env vars via command line. As you can imagine setting this up in a single command can be cumbersome.

If I have understood this correct so far, I would suggest you have wrapper shell scripts that sets these values appropriately and invoke gauge specs. Alternatively you can configure your Jenkins pipeline to set the correct env variables per run.

Does this help?

thanks
Srikanth

PS - My previous reply assumed that the values will be fixed per environment. In which case you can use Gauge's environment feature, and save the env vars in one of the .properties file instead of the shell script.

Sreejith Edayillam

unread,
Apr 4, 2017, 7:12:54 AM4/4/17
to getgauge
Thank You Sreekanth.

This helped to resolve the problem i was facing. 

Thanks a lot!! :)

-Sreejith.
Reply all
Reply to author
Forward
0 new messages