由于管道节点和进程插件的版本2.5(管道插件的组件,默认情况下已安装),因此
WORKSPACE环境变量再次可用。该版本发布于2016-09-23,因此应该在所有最新的Jenkins实例上可用。
例
node('label'){ // now you are on slave labeled with 'label' def workspace = WORKSPACE // ${workspace} will now contain an absolute path to job workspace on slave workspace = env.WORKSPACE // ${workspace} will still contain an absolute path to job workspace on slave // When using a GString at least later Jenkins versions could only handle the env.WORKSPACE variant: echo "Current workspace is ${env.WORKSPACE}" // the current Jenkins instances will support the short syntax, too: echo "Current workspace is $WORKSPACE"}


