How to get environment variable in Jenkins Groovy script console?

后端 未结 2 1890
伪装坚强ぢ
伪装坚强ぢ 2020-12-17 17:31

In Jenkins configuration (http://JenkinsURL/configure) within \"Global properties\" I defined some \"Environment variables\".

How can I access them in the Groovy Scr

2条回答
  •  情深已故
    2020-12-17 18:11

    You can use System to get environment variables.

    def env = System.getenv()
    println(env['JENKINS_HOME'])
    

    (See also http://@myJenkHostname@/env-vars.html (where @myJenkHostname@ is your Jenkins hostname) for a list of built-in environment variables.)

提交回复
热议问题