Environment variable in Jenkins Pipeline

后端 未结 2 1886
半阙折子戏
半阙折子戏 2021-02-01 14:19

Is there any environment variable available for getting the Jenkins Pipeline Title?

I know we can use $JOB_NAME to get title for a freestyle job, but is th

2条回答
  •  星月不相逢
    2021-02-01 14:37

    You can access the same environment variables from groovy using the same names (e.g. JOB_NAME or env.JOB_NAME).

    From the documentation:

    Environment variables are accessible from Groovy code as env.VARNAME or simply as VARNAME. You can write to such properties as well (only using the env. prefix):

    env.MYTOOL_VERSION = '1.33'
    node {
      sh '/usr/local/mytool-$MYTOOL_VERSION/bin/start'
    }
    

    These definitions will also be available via the REST API during the build or after its completion, and from upstream Pipeline builds using the build step.

    For the rest of the documentation, click the "Pipeline Syntax" link from any Pipeline job

提交回复
热议问题