Maven清理部署失败

时间:2017-10-02 08:05:04

标签: maven jenkins groovy

在我的Jenkins管道中,我尝试构建Maven Surefire插件,这样我就可以在管道中运行Maven Test并忽略测试的失败(以便管道流程可以继续):

mvn clean deploy -Dmaven.test.failure.ignore=false

但是,如果我尝试使用该命令,则会出现以下错误:

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
                                 ^

我不太明白为什么它不会工作,有人可以解释一下吗?

2 个答案:

答案 0 :(得分:1)

您对Maven的命令行调用被解释为groovy命令。这意味着您在groovy脚本中出现了语法错误。

答案 1 :(得分:0)

哟需要使用管道maven插件并使用shell步骤运行maven调用:

https://wiki.jenkins.io/display/JENKINS/Pipeline+Maven+Plugin

示例:

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