How to continue and not fail build on error in Exec Maven Plugin execution?

2.4k views Asked by At

How can the maven build be made to continue despite an error in one of the execution added by the Maven exec plugin?

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

2

There are 2 answers

0
rob2universe On BEST ANSWER

Example solution using success code:

<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>
0
Gebezs On

You can use successCodes and list the error codes what you want to treat as success. This was created for non-compliant application according to the docs docs but it is useful for such scenario.

I don't know any wildcard solution so you have to explicitly state the list of error codes for the successCodes.