rob2universe
rob2universe

Reputation: 7628

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

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

Upvotes: 3

Views: 2996

Answers (2)

rob2universe
rob2universe

Reputation: 7628

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>

Upvotes: 7

Gebezs
Gebezs

Reputation: 746

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.

Upvotes: 1

Related Questions