2017-01-09 4 views
2

groovy를 배우기 시작했습니다. svnSourcePath와 svnDestPath를 svn copy 명령의 쉘 스크립트에 전달하고 싶습니다. 그러나 URL은 렌더링되지 않습니다. 출력그루비 변수를 쉘 스크립트에 넘겨주세요.

+ 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

이 질문을 downvoted 사람 - 설명없이 downvoting의 요점은 무엇입니까? –

답변

4

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 ''' 
} 
} 

변수 주위 따옴표 OPERATOR 시스템을 플러스 ("+ 변수 + ')를 첨가. 이제 작동 중입니다.

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

""" content $var """을 사용할 수 있습니다. """은이 문서에서 문자열 보간을 허용합니다. ''' 않습니다.

다음 Selvam의 대답

1

하나는 매개 변수 플러그인 내 사용 사례입니다 : 문자열 매개 변수 이름 : 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받는