docker-maven-plugin: Configuration option to execute docker:stop in case of the failing build

Description

We use the plugin the start some docker images in the pre-integration-test phase and stop them in the post-integration-test. This works very well. However, if any of the integration tests fails the build, then the created docker containers remain running. Thus, it would be great if there would be a configuration option to run docker:stop in case the build fails. This way everything would be cleaned up correctly.

This is a feature request, however I am not sure how hard it is to implement this or if it’s possible at all.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 6
  • Comments: 25 (8 by maintainers)

Most upvoted comments

+1 the container is not stopping incase of test failures. But I use surefire to run my test.

@rohanKanojia Sure. I will try to have a look in the following days at the source and send a PR.

I had the same issue, I fixed it by separating the goals integration-test and verify into their own executions. Spent a few hours on this and then I got the hint after RTFM

Maybe it’s not a bad idea to stop the container after some time/phase by default.

            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>3.0.0-M5</version>
                <configuration>
                    ...
                </configuration>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                        <configuration>
                            ...
                        </configuration>
                    </execution>
                    <execution>
                        <id>verify</id>
                        <goals>
                            <goal>verify</goal>
                        </goals>
                        <configuration>
                            ...
                        </configuration>
                    </execution>
                </executions>
            </plugin>

I’m using it to start a server that connects to an external SOAP API.

Subscribed to this thread as I am facing the same problem.