我的dockerfile:
FROM openjdk:8u201-jdk-alpine3.9
ADD target/app-snapshot-0.0.1.jar .
在gitlab-ci Runner中,在进行Maven构建过程中:
maven:
image: maven:3-jdk-8
stage: maven
script:
- "mvn clean package -e"
artifacts:
name: "app-snapshot"
paths:
- ./target/app-snapshot-0.0.1.jar
build:
stage: build
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- BUILD_IMAGE_NAME=$CI_REGISTRY_IMAGE:`echo "$CI_BUILD_REF_NAME" | tr /# _`
- docker build --pull --force-rm=true -t "$BUILD_IMAGE_NAME" .
- docker push "$BUILD_IMAGE_NAME"
但是,当我在提交,更改等之后使用docker映像时,仍然看到第一个应用程序.jar,没有任何更改。
我的错误在哪里?我希望在构建过程之后看到我在artifacts jar应用程序中所做的所有更改。
答案 0 :(得分:1)
我无法复制问题,但是有一些方法可以“解决”:
maven:
image: maven:3-jdk-8
stage: maven
script:
- "mvn clean package -e"
artifacts:
name: "app-snapshot"
paths:
- ./target/app-snapshot-0.0.1.jar
.gitlab-ci.yml
:
artifacts:
name: "app-snapshot"
paths:
- target/*.jar
Dockerfile
:
FROM openjdk:8u201-jdk-alpine3.9
ADD target/*.jar .
使用dependencies
docs:
在构建作业时,定义来自maven的依赖项:
build:
stage: build
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- BUILD_IMAGE_NAME=$CI_REGISTRY_IMAGE:`echo "$CI_BUILD_REF_NAME" | tr /# _`
- docker build --pull --force-rm=true -t "$BUILD_IMAGE_NAME" .
- docker push "$BUILD_IMAGE_NAME"
dependencies:
- maven
artifacts:expire
docs .gitlab-ci.yml
:
artifacts:
name: "app-snapshot"
expire_in: 15 min #Just a example
paths:
- target/*.jar