2017-01-09 9 views
2

groovyを学び始めました。svnSourcePathとsvnDestPathをsvn copyコマンドのシェルスクリプトに渡したいと思います。しかしURLはレンダリングされません。シェルスクリプトにgroovy変数を渡す

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 
+0

この質問を落とした人 - 説明なしでdownvotingのポイントは何ですか? –

答えて

4

は、変数の周りに( '+変数+')単一引用符とプラスoperaterを追加しました。今すぐ動作しています

svn copy '''+svnSourcePath+' '+svnDestPath+''' -m 'promote dev to test' --username $SVN_USER --password $SVN_PWD ''' 
1

""" content $var """を使用できます。 """は、ここの文書で文字列補間が可能です。 '''はありません。

次Selvamの答えに

1

1は、パラメータのプラグインと私のユースケースである: Stringパラメータ名:pipelineParameter デフォルト値:4

node { 
    stage('test') { 
     withCredentials([[...]]) { 
      def pipelineValue = "${pipelineParameter}" //declare the parameter in groovy and use it in shellscript 
      sh ''' 
      echo '''+pipelineValue+' abcd'''' 
      ''' 
     } 
}} 

上記プリント4 ABCDへ

関連する問題