In my Jenkins pipeline I try to build in the Maven Surefire Plugin so I can run Maven Test within the Pipeline and ignore the failure of the Test (so that the pipeline process can go on):
mvn clean deploy -Dmaven.test.failure.ignore=false
However if I try to use the command I get following error:
class org.codehaus.groovy.ast.expr.UnaryMinusExpression, with its value 'Dmaven.test.failure.ignore', is a bad expression as the left hand side of an assignment operator at line: 6 column: 51. File: WorkflowScript @ line 6, column 51.
oy -Dmaven.test.failure.ignore=false
^
I don't quite understand why it won't work, can anyone explain?
Your command line call of Maven is interpreted as groovy command. This means that you made a syntax error in your groovy script.
Yo need to use the pipeline maven plugin and run the maven call with a shell step:
https://wiki.jenkins.io/display/JENKINS/Pipeline+Maven+Plugin
Example:
withMaven(
// Maven installation declared in the Jenkins "Global Tool Configuration"
maven: 'M3',
// Maven settings.xml file defined with the Jenkins Config File Provider Plugin
// Maven settings and global settings can also be defined in Jenkins Global Tools Configuration
mavenSettingsConfig: 'my-maven-settings',
mavenLocalRepo: '.repository') {
// Run the maven build
sh "mvn clean deploy -Dmaven.test.failure.ignore=false"
} // withMaven will discover the generated Maven artifacts, JUnit Surefire & FailSafe reports and FindBugs reports
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.