繁体   English   中英

导出命令在Jenkins Groovy中不起作用

[英]export command not working in Jenkins groovy

 export vara=$(grep '<Pattern>' $some_path/config/...../coreapplication_obips1/instanceconfig.xml | awk -F \> '{print $3}' | awk -F \< '{print $1}')

我正在使用groovy脚本在Jenkins管道中尝试上述代码。 它抛出以下错误:

at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310

如何在Jenkins Groovy中执行Shell脚本?

请参考以下内容运行shell并将输出捕获到Jenkins groovy文件内的变量中:

vara = sh (script: 'shell script need to be executed', returnStdout: true)

您可以尝试这样的事情:

      steps {
         script {
                vara = sh (script: '''shell command''', returnStdout: true)
                echo " The value of variable id ${vara}"
                }
       }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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