Accessing Jenkins global property in Groovy

后端 未结 4 1479
死守一世寂寞
死守一世寂寞 2021-02-10 18:20

At this moment I defined a environment variable called GLOBAL_VAR with the value \'test\' under Manage Jenkins -> Configure System -> Global Properties. I have a shell script wh

4条回答
  •  無奈伤痛
    2021-02-10 19:03

    Does anyone know how to access the Jenkins environment variables in groovy?

    I can provide an example from a Jenkins job we use. The job is parameterized and provides the user with the ability to set many values, one of which is "InstallVersion" (default value is -1). Additionally, we set up an environment variable called "JENKINS_TRUNK_LABEL". I won't go into specifics about this job, but, here's how we refer to "JENKINS_TRUNK_LABEL" within a Groovy script.

    if (InstallVersion == "-1")
    {
      InstallVersion = "$JENKINS_TRUNK_LABEL"
    }
    

提交回复
热议问题