将groovy变量传递给shell脚本 [英] Pass groovy variable to shell script
本文介绍了将groovy变量传递给shell脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚开始学习groovy.我想将svnSourcePath和svnDestPath传递给svn copy命令中的shell脚本.但网址未呈现.
I just started learning groovy.I want to pass the svnSourcePath and svnDestPath to shell script in the svn copy command. But URL not rendered.
node {
stage 'Copy Svn code'
def svnSourcePath = "${svnBaseURL}${svnAppCode}${svnEnvDev}${SVN_DEV_PACKAGE}"
def svnDestPath = "${svnBaseURL}${svnAppCode}${svnEnvTest}${SVN_DEV_PACKAGE}"
print "DEBUG: svnSourcePath = ${svnSourcePath}"
print "DEBUG: svnDestPath = ${svnDestPath}"
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: crendentialsIdSVN, passwordVariable: 'SVN_PWD', usernameVariable: 'SVN_USER']]) {
sh '''
svn copy $svnSourcePath $svnDestPath -m 'promote dev to test' --username $SVN_USER --password $SVN_PWD '''
}
}
输出
+ svn copy -m 'promote dev to test' --username techuser --password 'xxxyyy'
svn: E205001: Try 'svn help' for more info
svn: E205001: Not enough arguments provided
推荐答案
在变量周围加上了单引号并加上了operator('+ variable +').现在可以了
added the single quotes and plus operater('+ variable +') around the variable. Now it is working
svn copy '''+svnSourcePath+' '+svnDestPath+''' -m 'promote dev to test' --username $SVN_USER --password $SVN_PWD '''
这篇关于将groovy变量传递给shell脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文