'How to export variables in Jenkins workspace?

I'm trying to automate Jenkins installation, passing username and password in a Groovy script that start with jenkins server, but I noticed that the variables exported in bash, /etc/profile or /etc/environment are not visible in the script. If I use:

def env = System.getenv()
env each {
  println
} 

I see many variables, but none that I declared. Someone can point me in the right direction here?

Thank you all!!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source