繁体   English   中英

如何通过Jenkins Pipeline插件中的groovy脚本访问全局环境

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM