Sel*_*ran 6 shell groovy jenkins cloudbees
我刚开始学习groovy.我想在svn copy命令中将svnSourcePath和svnDestPath传递给shell脚本.但URL未呈现.
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 '''
}
}
Run Code Online (Sandbox Code Playgroud)
产量
+ 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
Run Code Online (Sandbox Code Playgroud)
在变量周围添加单引号和加上operater('+ variable +').现在它正在运作
svn copy '''+svnSourcePath+' '+svnDestPath+''' -m 'promote dev to test' --username $SVN_USER --password $SVN_PWD '''
Run Code Online (Sandbox Code Playgroud)
+1 对 Selvam 的回答
以下是我使用参数插件的用例
字符串参数名称:pipelineParameter
默认值:4
node {
stage('test') {
withCredentials([[...]]) {
def pipelineValue = "${pipelineParameter}" //declare the parameter in groovy and use it in shellscript
sh '''
echo '''+pipelineValue+' abcd''''
'''
}
}}
Run Code Online (Sandbox Code Playgroud)
上面打印了 4 abcd
| 归档时间: |
|
| 查看次数: |
9127 次 |
| 最近记录: |