1

I have to access an environment variable from my Groovy script. I am not using Jenkins. How do I get the variable?

Michael S.
  • 436
  • 6
  • 22
  • Have you tried https://stackoverflow.com/questions/21236268/access-to-build-environment-variables-from-a-groovy-script-in-a-jenkins-build-st? Have you tried: https://stackoverflow.com/questions/40215394/how-to-get-environment-variable-in-jenkins-groovy-script-console Have you tried: https://stackoverflow.com/questions/38599641/jenkins-pipeline-accessing-environment-variables ... What _have_ you tried? – tim_yates Aug 19 '19 at 13:57

1 Answers1

2

Use java.lang.System#getenv(java.lang.String)

Example:


def envVar = System.getenv('my_env_var')
Peter
  • 4,291
  • 1
  • 17
  • 31