我在jenkinsfile中编写一个阶段,我必须添加一些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 /)
"""
}
任何想法如何通过这个,错误似乎是我将echo输出分配给artifactId的方式。
答案 0 :(得分: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 /) """
}