java - Gitlab:您指定的目标需要一个项目来执行,但该目录中没有POM

标签 java maven continuous-integration gitlab

我尝试使用 gitlab CI 来构建和运行我的测试。

我使用默认的 .gitlab-ci.yml:

# This file is a template, and might need editing before it works on your project.
---
# Build JAVA applications using Apache Maven (http://maven.apache.org)
# For docker image tags see https://hub.docker.com/_/maven/
#
# For general lifecycle information see https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
#
# This template will build and test your projects as well as create the documentation.
#
# * Caches downloaded dependencies and plugins between invocation.
# * Verify but don't deploy merge requests.
# * Deploy built artifacts from master branch only.
# * Shows how to use multiple jobs in test stage for verifying functionality
#   with multiple JDKs.
# * Uses site:stage to collect the documentation for multi-module projects.
# * Publishes the documentation for `master` branch.

variables:
  # This will supress any download for dependencies and plugins or upload messages which would clutter the console log.
  # `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
  MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
  # As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used
  # when running from the command line.
  # `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins.
  MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"

# Cache downloaded dependencies and plugins between builds.
# To keep cache across branches add 'key: "$CI_JOB_NAME"'
cache:
  paths:
    - .m2/repository

# This will only validate and compile stuff and run e.g. maven-enforcer-plugin.
# Because some enforcer rules might check dependency convergence and class duplications
# we use `test-compile` here instead of `validate`, so the correct classpath is picked up.
.validate: &validate
  stage: build
  script:
    - 'mvn $MAVEN_CLI_OPTS test-compile'

# For merge requests do not `deploy` but only run `verify`.
# See https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
.verify: &verify
  stage: test
  script:
    - 'mvn $MAVEN_CLI_OPTS verify site site:stage'
  except:
    - master

# Validate merge requests using JDK7
validate:jdk7:
  <<: *validate
  image: maven:3.3.9-jdk-7

# Validate merge requests using JDK8
validate:jdk8:
  <<: *validate
  image: maven:3.3.9-jdk-8

# Verify merge requests using JDK7
verify:jdk7:
  <<: *verify
  image: maven:3.3.9-jdk-7

# Verify merge requests using JDK8
verify:jdk8:
  <<: *verify
  image: maven:3.3.9-jdk-8


# For `master` branch run `mvn deploy` automatically.
# Here you need to decide whether you want to use JDK7 or 8.
# To get this working you need to define a volume while configuring your gitlab-ci-multi-runner.
# Mount your `settings.xml` as `/root/.m2/settings.xml` which holds your secrets.
# See https://maven.apache.org/settings.html
deploy:jdk8:
  # Use stage test here, so the pages job may later pickup the created site.
  stage: test
  script:
    - 'mvn $MAVEN_CLI_OPTS deploy site site:stage'
  only:
    - master
  # Archive up the built documentation site.
  artifacts:
    paths:
    - target/staging
  image: maven:3.3.9-jdk-8


pages:
  image: busybox:latest
  stage: deploy
  script:
    # Because Maven appends the artifactId automatically to the staging path if you did define a parent pom,
    # you might need to use `mv target/staging/YOUR_ARTIFACT_ID public` instead.
    - mv target/staging public
  dependencies:
    - deploy:jdk8
  artifacts:
    paths:
    - public
  only:
    - master

当我运行管道时,它失败并收到以下错误:

2288 [错误] 您指定的目标需要一个项目来执行,但此目录 (/builds/IceCristall/the-great-triggering) 中没有 POM。请验证您从正确的目录调用 Maven。 -> [帮助1] org.apache.maven.lifecycle.MissingProjectException:您指定的目标需要一个项目来执行,但此目录中没有 POM (/builds/IceCristall/the-great-triggering)。请验证您从正确的目录调用了 Maven。

这是完整的日志:

Running with gitlab-runner 11.2.0-rc2 (1644837a)
  on docker-auto-scale ed2dce3a
Using Docker executor with image maven:3.3.9-jdk-8 ...
Pulling docker image maven:3.3.9-jdk-8 ...
Using docker image sha256:9997d8483b2fc521a4159feab922546dda0c5c22b5084f86dfab48f123ae4364 for maven:3.3.9-jdk-8 ...
Running on runner-ed2dce3a-project-7913048-concurrent-0 via runner-ed2dce3a-srm-1534626556-3eb27695...
Cloning repository...
Cloning into '/builds/IceCristall/the-great-triggering'...
Checking out e41a61bd as master...
Skipping Git submodules setup
Checking cache for default...
FATAL: file does not exist                         
Failed to extract cache
$ mvn $MAVEN_CLI_OPTS test-compile
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T16:41:47+00:00)
Maven home: /usr/share/maven
Java version: 1.8.0_121, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "4.14.48-coreos-r2", arch: "amd64", family: "unix"
2053 [INFO] Error stacktraces are turned on.
2152 [INFO] Scanning for projects...
2252 [INFO] ------------------------------------------------------------------------
2253 [INFO] BUILD FAILURE
2253 [INFO] ------------------------------------------------------------------------
2254 [INFO] Total time: 0.133 s
2254 [INFO] Finished at: 2018-08-18T21:12:14+00:00
2286 [INFO] Final Memory: 6M/56M
2287 [INFO] ------------------------------------------------------------------------
2288 [ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/builds/IceCristall/the-great-triggering). Please verify you invoked Maven from the correct directory. -> [Help 1]
org.apache.maven.lifecycle.MissingProjectException: The goal you specified requires a project to execute but there is no POM in this directory (/builds/IceCristall/the-great-triggering). Please verify you invoked Maven from the correct directory.
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:84)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
2299 [ERROR] 
2299 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
2299 [ERROR] 
2299 [ERROR] For more information about the errors and possible solutions, please read the following articles:
2300 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException
ERROR: Job failed: exit code 1

当我正确理解此日志时,该项目是从路径下的 Docker 容器中的我的存储库复制的:/builds/IceCristall/the-great-triggering

现在执行mvn命令并没有找到pom.xml

我有点困惑,因为 pom.xml 位于“the-great-triggering”文件夹中。

此外,我找不到可以在 ci 配置文件中定义此路径的位置。

有人对问题所在以及我可以在哪里搜索它有建议吗?

最佳答案

错误消息显示:“此目录 (/builds/IceCristall/the-great-triggering) 中没有 POM。”。 您确定已提交 pom.xml 文件并将其推送到存储库的所需分支吗?

关于java - Gitlab:您指定的目标需要一个项目来执行,但该目录中没有POM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51912817/

相关文章:

java - 好极了。按嵌套映射的键对映射数组进行排序

java - 将属性文件与 Maven 程序集合并

java - 当没有找到测试结果时,如何跳过 Allure 报告生成?

linux - 如何将 bamboo 变量从 Bamboo 脚本发送到 docker 容器?

tfs - TFS 中的构建历史太短

vue.js - 在 CI 管道中运行开发服务器

java - 这里的内存分配是怎么回事?

java - 如何在java中更改操作系统时区?

Java JAX-WS xs :dateTime with format UTC and Local

maven - 如何让 Nexus 获取代理存储库中的 Artifact 文件?