【问题标题】:How to continue and not fail build on error in Exec Maven Plugin execution?如何在 Exec Maven 插件执行中继续并且不会因错误而失败?
【发布时间】:2021-04-12 22:44:22
【问题描述】:

尽管 Maven exec 插件添加的其中一个执行出现错误,如何使 maven 构建继续?

https://www.mojohaus.org/exec-maven-plugin/usage.html

【问题讨论】:

    标签: maven maven-3 maven-exec-plugin


    【解决方案1】:

    使用成功代码的示例解决方案:

    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>exec-maven-plugin</artifactId>
      <version>3.0.0</version>
      <executions>
        <execution>
          <id>docker-rmi</id>
            <phase>clean</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>docker</executable>
              <workingDirectory>${project.basedir}</workingDirectory>
              <arguments>
                <argument>rmi</argument>
                <argument>${project.groupId}/${project.artifactId}:${project.version</argument>
              </arguments>
              <successCodes>
                <successCode>0</successCode>
                <successCode>1</successCode>
              </successCodes>
            </configuration>
        </execution>
      </executions>
    </plugin>
    

    【讨论】:

      【解决方案2】:

      您可以使用successCodes 并列出您希望视为成功的错误代码。 这是根据文档 docs 为不合规的应用程序创建的,但它对这种情况很有用。

      我不知道任何通配符解决方案,因此您必须明确说明successCodes 的错误代码列表。

      【讨论】:

        猜你喜欢
        • 2018-10-07
        • 1970-01-01
        • 2017-01-07
        • 1970-01-01
        • 2011-03-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-05-30
        相关资源
        最近更新 更多