2017-06-28 23 views
2

我在jenkinsfile中編寫了一個階段,我必須添加一些bash代碼,但不在最後一行編譯。在groovy文件/ Jenkins文件中運行一些bash代碼

stage('Pre Build Stage') { 

    def deploy_property_basename = "deploy" 
    sh """ 
    mkdir $WORKSPACE/resp 
    cd $WORKSPACE 
    git clone -b master ${env.GIT_REPO} build  
    cd $WORKSPACE/build 
    cp pom.xml .. 
    artifactId=$(echo -e 'setns x=http://maven.apache.org/POM/4.0.0\ncat /x:project/x:artifactId/text()' | xmllint --shell ./pom.xml | grep -v /) 
    """ 
} 

任何想法我怎麼能通過這個,錯誤似乎是我分配回聲輸出到artifactId的方式。

回答

3

你錯過了「臺階」宣言嘗試

stage('Pre Build Stage') { 

def deploy_property_basename = "deploy" 
steps{ 
sh """ 
    mkdir $WORKSPACE/resp 
    cd $WORKSPACE 
    git clone -b master ${env.GIT_REPO} build  
    cd $WORKSPACE/build 
    cp pom.xml .. 
    artifactId=$(echo -e 'setns x=http://maven.apache.org/POM/4.0.0\ncat /x:project/x:artifactId/text()' | xmllint --shell ./pom.xml | grep -v /) """ 
} 
+0

快樂幫,歡迎堆棧溢出!如果此答案或任何其他人解決了您的問題,請將其標記爲已接受。 – bjamin