intellibot icon indicating copy to clipboard operation
intellibot copied to clipboard

Support for environment variables in resource path.

Open pselden opened this issue 10 years ago • 7 comments

Is it possible to add support for environment variables when resolving resource paths?

For instance:

Resource            %{TESTS_HOME}/my_tests/resources.txt

Where TESTS_HOME is an environment variable that points to something like /Users/me/tests

Currently it just errors with "Import file not found"

pselden avatar Aug 10 '15 13:08 pselden

where or how do you define %{TESTS_HOME}?

mtrubs avatar Aug 10 '15 18:08 mtrubs

The %{} is used to tell Robot that it's an environment variable and not a defined variable.

For instance, in your bash profile or when running from the command line (different on Windows/Unix but here's with Unix + bash):

Inside your .bash_profile export TESTS_HOME=~/tests

From command line: TESTS_HOME=~/tests pybot test-suite.robot

This can be retrieved in Java as: System.getenv("TESTS_HOME");

pselden avatar Aug 11 '15 13:08 pselden

how would one define these in intellij? I need to know how to setup my environment with one so that I know I can correctly get it out of the system.

mtrubs avatar Aug 24 '15 15:08 mtrubs

They aren't Intellij specific things but rather "environment" (meaning your current login session) defined variables.

For windows: https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/sysdm_advancd_environmnt_addchange_variable.mspx?mfr=true For unix/mac (depends what shell you use but instructions for multiple shells are here): http://www.cyberciti.biz/faq/set-environment-variable-unix/

Setting them is different depending on what operating system you're in, but they can always be retrieved with the System.getenv call in Java.

pselden avatar Aug 24 '15 17:08 pselden

I get what they are and how one might use them. I do not understand how IntelliJ/PyCharm would be aware. So you are saying you just do an export in your bash profile and IntelliJ/PyCharm should be able to pick this up? Do you happen to know of any other plugins that are able to make use of this data? I can try testing out a couple of things but I worry that its going to be a little different (as everything seems to be with plugin development).

mtrubs avatar Aug 25 '15 13:08 mtrubs

So you are saying you just do an export in your bash profile and IntelliJ/PyCharm should be able to pick this up

Ahh -- sorry I was being dense and didn't realize the issue here. From windows you can set "global" environment variables using the method mentioned in the article. From Mac you'd have to use something like mentioned here: http://www.dowdandassociates.com/blog/content/howto-set-an-environment-variable-in-mac-os-x-slash-etc-slash-launchd-dot-conf/ because IntelliJ won't be inheriting variables from your shell.

Note -- the IntelliJ python plugin just lets you enter environment variables directly (not sure if you'd actually need this if the other methods worked).

screen shot 2015-08-25 at 9 40 29 am

pselden avatar Aug 25 '15 13:08 pselden

Is this in any way planned?

Is the --variable flag support related to this / planned?

stdedos avatar May 22 '19 09:05 stdedos