I don't get that.
The jenkins help clearly says that the Environment variables section from the Node Properties will overwrite the one from the Configure System page.
So either the logic or the documentation should be changed.
Although from my point of view it is more reliable to have environment variables like JAVA_HOME that can be used by scripts then setting these environment variables inside the script.
If I set them inside scripts I am bound to a fixed path and the script can't be executed on systems where this path doesn't exist. If I use the environment variable that the system defines it is irrelevant where java has been installed.
Unfortunately using the withEnv step also doesn't solve the problem. In our setup we are building on the master as well on the agents but need
a different configuration for the agents.
In our case if a developer decides to build his feature branch he starts a vm that automatically connects to jenkins as an agent.
To make it easy for the developer to find his agent the hostname of the developers pc is incorporated into the agent name.
Therefore it's not possible to check for the agent name in Jenkinsfiles and use different environment settings because I don't know the name of the Agent.