1

I have a machine on which I'm writing the code and I'm executing the code on a different machine locally by using port forwarding. In this case, if I set IntelliJ environment variables in my local machine IntelliJ (The machine in which I'm writing the code), will it be read on the remote machine? Basically I'm confused about where IntelliJ sets this environment variable and whether its global?

I have set the environment variable under "Run Configurations" by the way.

AnOldSoul
  • 4,017
  • 12
  • 57
  • 118
  • They are local to your machine and your machine only (well actually only when running things through Intelllij). – M. Deinum Aug 28 '20 at 18:26
  • Do I have to set this in the code if the code is getting executed in another machine? Or does IntelliJ set the variable on the machine it runs? – AnOldSoul Aug 28 '20 at 18:27
  • What specific run/debug configuration type do you use to run your code on a remote machine? – CrazyCoder Aug 28 '20 at 18:36
  • The run configuration is simply a Test NG run config. And I'm launching Selenium browser on a remote machine by port forwarding the chrome driver port. This is where I'm confused if the code will read the eenv variable from my local or whether it'll be looking for it in the remote machine where the browser is launched – AnOldSoul Aug 28 '20 at 18:39

2 Answers2

1

IntelliJ IDEA TestNG run configuration does nothing to pass the environment variables to the remote machine, they will be set for the local machine only. You need to do it from your code that runs on the remote system.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
0

A process gets environment variables from the operating system that starts it. They have to be set on remote machine before the process is started.

That's why you can see a text box for entering environment variables in IntelliJ only for local configurations (e.g. "Application", "JUnit" etc.). There is no such text box for "Remote" configurations.

"Remote" configurations only attach to remote process via debugging port, and in this case the process has to be already running.

You need to run this on the remote machine:

export VARIABLE=value
java -cp classpath MainClass
jurez
  • 4,436
  • 2
  • 12
  • 20