GitLab CI 因 maven-surefire-plugin 和 VM 崩溃而失败 [英] GitLab CI is failing due to maven-surefire-plugin with VM crash

查看:45
本文介绍了GitLab CI 因 maven-surefire-plugin 和 VM 崩溃而失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有大约 10 个不同的应用程序,它们是带有 Groovy 的 Spring Boot 项目.

We have around of 10 different applications that are Spring Boot projects with Groovy.

我们所有的项目都在所有开发人员工作站中正确构建,并且直到昨天它们都在正常运行,但是今天突然间它们都停止了,只在我们的 GitLab CI 管道中停止工作,并出现以下错误:

All of our projects build correctly in all developer work stations and they were running correctly until yesterday, however suddenly all of them stopped working today only in our GitLab CI pipelines with below error:

[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:37 min
[INFO] Finished at: 2018-10-31T17:49:11Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.21.0:test (default-test) on project ctg-oms-component: There are test failures.
[ERROR] 
[ERROR] Please refer to /builds/ctg-integrations/ctg-oms-component/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[ERROR] ExecutionException The forked VM terminated without properly saying goodbye. VM crash or System.exit called?

我已经提取了使用我们的 GitLab CI 管道的相同 docker 映像,测试了构建项目并且一切正常.但是,该错误仅发生在 GitLab CI 中.

I've pulled the same docker image that is using our GitLab CI pipeline, tested building the project and everything works correctly. However, the error occurs only in GitLab CI.

经过调查,看起来surefire 正在创建一个导致 GitLab CI docker 崩溃的分叉.为了解决这个问题,我在下面添加了显式配置以避免分叉 VM,这消除了上述错误.

After an investigation looks like surefire is creating a fork that makes GitLab CI docker crash. In order to fix this, I've added below explicit configuration to avoid forked VM and this got rid of above error.

<!-- Needed only for GitLab CI -->
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <forkCount>0</forkCount>
    </configuration>
</plugin>

你知道为什么会这样吗?是否有另一种方法来修复 GitLab CI 以避免此问题?我不太喜欢这种解决方法,因为它只是避免 GitLab CI 爆炸的一种方法,但不知道 Gitlab 中如何在幕后处理 Docker.

Do you know why this is occurring? Is there another way to fix GitLab CI to avoid this issue? I don't really like this workaround, since it is just a way to avoid GitLab CI to explode but don't know how Docker is handled behind the scenes in Gitlab.

推荐答案

问题与最新的maven docker镜像有关.

The issues are related to the latest maven docker images.

有一个开放的 github 问题,人们报告了同样的问题:https://github.com/carlossg/docker-maven/issues/90

There is an open github issue where people reported the same problem: https://github.com/carlossg/docker-maven/issues/90

经过调查,我可以使用 alpine 版本解决问题,这让我无需添加 maven-surefire-plugin 解决方法.值得一提的是,使用 surefire 解决方法会带来另一个问题,例如 jacoco 之类的插件无法运行,因为它们需要 VM fork.

After an investigation I could sort out the problem using alpine version that saved me of adding the maven-surefire-plugin workaround. It's important to mention that using the surefire workaround brings another problem such as plugins like jacoco don't run since they need the VM fork.

因此,这些图像可以无缝运行(不需要万无一失的解决方法):

So, these images work seamlessly (no surefire workaround was needed):

  • maven:3.3.9-jdk-8
  • maven:3.5.3-jdk-8
  • maven:3.5.4-jdk-8-alpine
  • maven:3.6.0-jdk-8-alpine

但是,如果我们使用非 alpine 版本,问题仍然存在.

However if we use the non alpine version the issue persists.

这篇关于GitLab CI 因 maven-surefire-plugin 和 VM 崩溃而失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆