Gitlab CI.MVN 验证.无法执行目标



我尝试在本地构建:

mvn -B verify

一切正常。

.

gitlab-ci.yml :

image: maven:latest
verify-job:
  script:
    - mvn -B verify

检查了几个模块后,专家。我收到错误:

[INFO] Tree 1.0-0 ......................................... FAILURE [  7.587 s]

。跳

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:35 min
[INFO] Finished at: 2018-12-25T13:51:57Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project Tree: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test failed: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ? -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :Tree
ERROR: Job failed: exit code 1

没有模块使用依赖 org.apache.maven.plugins:maven-surefire-plugin我检查了SO上的另一个答案,但有同样的错误,没有人与CI GitLab集成有关。我可以猜到这与 ktlint 有关,但为什么本地构建会成功?

我找到了一个解决方案:只需添加到POM中.xml

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.0.0-M1</version>
    </plugin>

这里你可以去找解决方案,你的管道需要定义 jdk 包添加:

只需根据您的项目需求确保 java 版本:

Java_Build:
  stage: build
  image: 
    name: docker:20.10
  services:
    - docker:dind
  before_script:
    - apk update
    - apk add openjdk8
    - apk add maven
  script:
    - mvn -B verify

相关内容

最新更新