Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set an environment variable with gauge's current environment value #1333

Closed
zabil opened this issue Feb 5, 2019 · 8 comments
Closed

Set an environment variable with gauge's current environment value #1333

zabil opened this issue Feb 5, 2019 · 8 comments

Comments

@zabil
Copy link
Member

zabil commented Feb 5, 2019

While using Gauge's environment feature.
There must be a way to access the value of the environment used for execution from the runner.

For e.g

$ gauge run specs --env local

In Javascript

console.log(process.env.GAUGE_ENVIRONMENT) // Prints "local"

WORKAROUND

Set the environment variable and use it for execution for e.g. in bash

$ export GAUGE_ENVIRONMENT=local
$ gauge run specs --env $GAUGE_ENVIRONMENT
@gaugebot
Copy link

gaugebot bot commented Mar 13, 2019

The fix should be available in nightly >= 13-3-2019

@Debashis9012
Copy link
Contributor

This has been verified and found fixed with the below version:
Gauge version: 1.0.5.nightly-2019-03-28

@delmaamoun
Copy link

Hi, I am using this and it's working on windows but not linux:
env = os.getenv("GAUGE_ENVIRONMENT") returns a value when running on windows but not on linux.
If it's not set in the env. variable, where else can I know which env I'm running from the code?

Gauge version: 1.0.6
Commit Hash: 2bc49db

Plugins

flash (0.0.1)
html-report (4.0.8)
python (0.3.5)
screenshot (0.0.1)
spectacle (0.1.3)
xml-report (0.2.2)

@zabil
Copy link
Member Author

zabil commented Oct 29, 2019

Please try using the following and see if it works (notice the lower case)

env = os.getenv("gauge_environment")

@delmaamoun
Copy link

Yep that worked, thanks!

@zabil zabil reopened this Oct 29, 2019
@zabil
Copy link
Member Author

zabil commented Oct 29, 2019

Thanks for pointing this out.

Environment variables, by convention should be upper case. Gauge is currently not setting the values as upper case and this must be fixed to follow conventions.

@zabil
Copy link
Member Author

zabil commented Jan 24, 2020

Environment variables, by convention should be upper case. Gauge is currently not setting the values as upper case and this must be fixed to follow conventions.

Won't be doing this as this will break backwards compatibility and not predictable across platforms.

@zabil zabil closed this as completed Jan 24, 2020
@x80486
Copy link

x80486 commented Sep 25, 2021

I think GAUGE_ENVIRONMENT can be added, maintain both for a while, and set a path for gauge_environment deprecation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

6 participants