![](/img/trans.png)
[英]How to access a groovy variable in shell script in jenkins pipeline?
[英]How to access global environment through groovy script in Jenkins Pipeline Plugin
在shell中,我们使用以下命令
node{
sh "x=${env.j_properties_file}"
sh "y=${env.HOME}"
}
我们如何在groovy脚本中使用它或如何在groovy脚本中访问外壳变量x?
您不能直接访问它们,但是根据参考,您可以从sh
步骤中捕获stdout:
node{
def xx = sh(returnStdout:true, script:"""
x=${env.j_properties_file}
echo \${x}
""")
echo "the shell output = ${xx}"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.