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

Viewed 1069
2 Answers

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>

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.

Related