Environment variable in Jenkins Pipeline

后端 未结 2 1913
半阙折子戏
半阙折子戏 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:33

    To avoid problems of side effects after changing env, especially using multiple nodes, it is better to set a temporary context.

    One safe way to alter the environment is:

     withEnv(['MYTOOL_HOME=/usr/local/mytool']) {
        sh '$MYTOOL_HOME/bin/start'
     }
    

    This approach does not poison the env after the command execution.

提交回复
热议问题