Issue
My dockerfile:
FROM openjdk:8u201-jdk-alpine3.9
ADD target/app-snapshot-0.0.1.jar .
In gitlab-ci runner, during maven building process:
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_COMMIT_REF_NAME" | tr /# _`
- docker build --pull --force-rm=true -t "$BUILD_IMAGE_NAME" .
- docker push "$BUILD_IMAGE_NAME"
But, when I used docker image after commits, changes etc., still I see first application .jar, without changes.
Where is my mistake? I would like to see - after building process - all my changes in artifacts jar app.
Solution
I can't replicate the problem, but have some ways to "solve":
- Try to fix the indentation:
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
- Use patterns in artifacts: (It is good for when versions change you not need to change the code)
.gitlab-ci.yml
:
artifacts:
name: "app-snapshot"
paths:
- target/*.jar
Dockerfile
:
FROM openjdk:8u201-jdk-alpine3.9
ADD target/*.jar .
Use
dependencies
docs:In you build job define dependencies from 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_COMMIT_REF_NAME" | tr /# _`
- docker build --pull --force-rm=true -t "$BUILD_IMAGE_NAME" .
- docker push "$BUILD_IMAGE_NAME"
dependencies:
- maven
- Is a good practice use
artifacts:expire
docs
.gitlab-ci.yml
:
artifacts:
name: "app-snapshot"
expire_in: 15 min #Just a example
paths:
- target/*.jar
Answered By - jwillker
Answer Checked By - Timothy Miller (JavaFixing Admin)