cea-hpc / modules

Environment Modules: provides dynamic modification of a user's environment
http://modules.sourceforge.net/
GNU General Public License v2.0
695 stars 109 forks source link

Support for Groovy #446

Open xdelaruelle opened 2 years ago

xdelaruelle commented 2 years ago

Groovy language seems used in system like Jenkins to interact with user environment.

It could be interesting to add support for such language on Modules.

Groovy has capabilities to dynamically evaluate code and interact with user environment: http://groovy-lang.org/integrating.html

Need to check if a generic Groovy support could be made, or if there should be a support for each DSL derivated from Groovy.

nanobowers commented 3 months ago

First, I am not a Groovy expert, but I was intrigued by this enough to do a little research. It is not obvious to me if a generic Groovy support is possible. There is a System.getenv() to get system environment variables, but there is no System.setenv() to set them. There appear to be some workarounds, but they look more involved than setting environment variables in any other scripting languages I know of.

It appears Jenkins itself has some DSL that allows setting environment variables that is separate what is available in native Groovy, but that seems like a very specific use model and possibly hard to test.