Gitlab CI/CD Maven Springboot上传 *JAR错误:没有此类文件或目录

发布于 2025-02-10 11:46:37 字数 1889 浏览 1 评论 0原文

我正在尝试设置Springboot Monorepo Gitlab管道,但是无法找到工件。

MVN作业

maven-package:
  stage: package
  inherit:
    default: true
    variables: true
  script:
    - cd springboot
    - mvn clean package -P dev
    - cd target
    - ls -al
  artifacts:
    when: always
    paths:
      - springboot.jar
  tags:
    - docker

日志

$ cd target
$ ls -al
total 41124
drwxr-xr-x 9 root root     4096 Jun 25 11:53 .
drwxrwxrwx 5 root root     4096 Jun 25 11:53 ..
drwxr-xr-x 4 root root     4096 Jun 25 11:53 classes
drwxr-xr-x 3 root root     4096 Jun 25 11:53 generated-sources
drwxr-xr-x 3 root root     4096 Jun 25 11:53 generated-test-sources
drwxr-xr-x 2 root root     4096 Jun 25 11:53 maven-archiver
drwxr-xr-x 3 root root     4096 Jun 25 11:53 maven-status
-rw-r--r-- 1 root root 42053990 Jun 25 11:53 springboot.jar
-rw-r--r-- 1 root root    13258 Jun 25 11:53 springboot.jar.original
drwxr-xr-x 2 root root     4096 Jun 25 11:53 surefire-reports
drwxr-xr-x 3 root root     4096 Jun 25 11:53 test-classes
Uploading artifacts for successful job
00:01
Uploading artifacts...
WARNING: springboot.jar: no matching files. Ensure that the artifact path is relative to the working directory 
ERROR: No files to upload                          
Cleaning up project directory and file based variables
00:00
Job succeeded

Dockerfile

FROM openjdk:latest
MAINTAINER vdoma.de
VOLUME /tmp
ADD target/springboot.jar  app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]

docker build Fail失败,因为找不到

docker日志错误的

ADD failed: file not found in build context or excluded by .dockerignore: stat target/springboot.jar: file does not exist
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1

工件是否有同样的问题?

I am trying to setup a Springboot monorepo GitLab Pipeline, but the artifacts couldn#t be found.

mvn job

maven-package:
  stage: package
  inherit:
    default: true
    variables: true
  script:
    - cd springboot
    - mvn clean package -P dev
    - cd target
    - ls -al
  artifacts:
    when: always
    paths:
      - springboot.jar
  tags:
    - docker

Job Log

$ cd target
$ ls -al
total 41124
drwxr-xr-x 9 root root     4096 Jun 25 11:53 .
drwxrwxrwx 5 root root     4096 Jun 25 11:53 ..
drwxr-xr-x 4 root root     4096 Jun 25 11:53 classes
drwxr-xr-x 3 root root     4096 Jun 25 11:53 generated-sources
drwxr-xr-x 3 root root     4096 Jun 25 11:53 generated-test-sources
drwxr-xr-x 2 root root     4096 Jun 25 11:53 maven-archiver
drwxr-xr-x 3 root root     4096 Jun 25 11:53 maven-status
-rw-r--r-- 1 root root 42053990 Jun 25 11:53 springboot.jar
-rw-r--r-- 1 root root    13258 Jun 25 11:53 springboot.jar.original
drwxr-xr-x 2 root root     4096 Jun 25 11:53 surefire-reports
drwxr-xr-x 3 root root     4096 Jun 25 11:53 test-classes
Uploading artifacts for successful job
00:01
Uploading artifacts...
WARNING: springboot.jar: no matching files. Ensure that the artifact path is relative to the working directory 
ERROR: No files to upload                          
Cleaning up project directory and file based variables
00:00
Job succeeded

Dockerfile

FROM openjdk:latest
MAINTAINER vdoma.de
VOLUME /tmp
ADD target/springboot.jar  app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]

Docker build fail because the artifacts could not have been found

Docker log error

ADD failed: file not found in build context or excluded by .dockerignore: stat target/springboot.jar: file does not exist
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1

did anyone have the same issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尴尬癌患者 2025-02-17 11:46:37
maven-package:
  stage: package
  inherit:
    default: true
    variables: true
  script:
    - cd springboot
    - mvn clean package -P dev
    - cd target
    - ls -al
  artifacts:
    when: always
    paths:
      - springboot/target/springboot.jar
  tags:
    - docker
FROM openjdk:latest
MAINTAINER vdoma.de
VOLUME /tmp
COPY springboot/target/springboot.jar  app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
maven-package:
  stage: package
  inherit:
    default: true
    variables: true
  script:
    - cd springboot
    - mvn clean package -P dev
    - cd target
    - ls -al
  artifacts:
    when: always
    paths:
      - springboot/target/springboot.jar
  tags:
    - docker
FROM openjdk:latest
MAINTAINER vdoma.de
VOLUME /tmp
COPY springboot/target/springboot.jar  app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文