I have to access an environment variable from my Groovy script. I am not using Jenkins. How do I get the variable?
Use java.lang.System#getenv(java.lang.String)
Example:
def envVar = System.getenv('my_env_var')
A shorter groovy way would be like this:
def envVar = System.env['my_env_var']
Here is an example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With