如何使可在Docker映像中构建的jar用作构建工件下载?

时间:2019-05-03 13:41:26

标签: java maven docker gitlab-ci

我正在将Java代码构建到Docker容器内的jar文件中:

[INFO] Building jar: /target/jartest.maven-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.101 s
[INFO] Finished at: 2019-04-15T16:43:32Z
[INFO] Final Memory: 14M/56M
[INFO] ------------------------------------------------------------------------

基于上述路径,我想将该jar作为构建工件下载。这是.gitlab-ci.yml文件中的定义:

artifacts:
    paths:
    - target/jartest.maven-1.0-SNAPSHOT.jar

但是,一旦构建完成,它说该文件不存在:

Uploading artifacts...
WARNING: target/jartest.maven-1.0-SNAPSHOT.jar: no matching files 
ERROR: No files to upload                          
Job succeeded

我如何实现目标?



附加说明:

这是.gitlab-ci.yml文件中的构建阶段:

build-master:
  stage: build-master
  script:
    - docker build --pull -t "$CI_REGISTRY_IMAGE" .
    - docker push "$CI_REGISTRY_IMAGE"

这是我的Dockerfile:

FROM maven:3.5.2-jdk-8 as BUILD
COPY . .
RUN mvn -f pom.xml test
RUN mvn -f pom.xml package

0 个答案:

没有答案