You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Activity
nanobowers commentedon Jun 28, 2024
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 noSystem.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.