我想从管道脚本中执行以下maven命令,但是连字符或引号不起作用
pipeline {
agent {
label 'master'
}
environment {
Blah
Blah..
}
stages {
stage('Build') {
steps {
sh "echo 'Build_Id: ' $BUILD_ID"
sh "echo 'Job_Name: ' $JOB_NAME"
sh "echo 'Build_Name: ' $BUILD_NAME"
sh "echo 'Current Branch Name: ' $BRANCH"
sh 'mvn clean package deploy -DskipTests -pl "AML-BI"'
}
}
}
}
post {
success {
}
failure {
}
always{
}
}
}
我尝试了单引号,双引号,反斜杠转义和连接,但是没有任何作用
[Pipeline] sh
[Business-Information-UK AML-BI] Running shell script
+ mvn clean package deploy -P buildserver02,!artifactory -DskipTests -pl AML-BI
[INFO] Scanning for projects...
[ERROR] [ERROR] Could not find the selected project in the reactor: AML-BI @
[ERROR] Could not find the selected project in the reactor: AML-BI -> [Help 1]
[ERROR]
这是项目中的模块“ AML-BI”,我希望脚本执行为
mvn clean package deploy -P buildserver02,!artifactory -DskipTests -pl "AML-BI"
答案 0 :(得分:4)
和我一样,如果您正在寻找解决方案,请将脚本行更改为:
sh "mvn clean deploy -P buildserver02,!artifactory -DskipTests -pl \\\"AML-BI\\\""
解决了这个难题,现在可以正常工作。感谢您的评论!
这是日志中的摘录:
[Pipeline] sh
[Some-Project-Information AML-BI] Running shell script
+ mvn clean deploy -P buildserver02,!artifactory -DskipTests -pl "AML-BI"
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building AML-BI
[INFO] ------------------------------------------------------------------------
Downloading: http://somebuildseriver/artifactory/libs-snapshot//0.0.1-SNAPSHOT/maven-metadata.xml
776/776 B
Downloaded: http://somebuildseriver/artifactory/libs-snapshot//0.0.1-SNAPSHOT/maven-metadata.xml (776 B at 3.8 KB/sec)
[INFO]
....