2017-06-28 22 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