Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Pipeline - How to use mvn build jar artifact in docker file

vidor01
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 7, 2018

In bitbucket-pipelines.yml

After mvn build the Jar file is saved to /opt/atlassian/pipelines/agent/build/target/ directory as per pipeline logs.

How do I use this location in the Dockerfile when building the image? Or set the location in pipelines?

Currently I get error: 

ADD failed: stat /var/lib/docker/165536.165536/tmp/docker-builder912665471/target/app-0.0.1-SNAPSHOT.jar: no such file or directory.

 

 

Dockerfile:

FROM openjdk:8-jdk-alpine

ADD ./target/app-0.0.1-SNAPSHOT.jar app.jar

EXPOSE 8081

ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]

 

 

1 answer

1 accepted

2 votes
Answer accepted
vidor01
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 10, 2018

Adding the following resolved this:

 

artifacts:
- target/**

varun.malhotra February 5, 2020

Hi lee,

 

Where you added the '-target/**'?

Like veselinnguyen likes this
veselinnguyen
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 13, 2020

I have the same question. WHere exactly the artifacts: -target is specified?

AnnMii89
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 1, 2020

Short answer: in bitbucket-pipelines.yml

Explanation:

Had the same issue. Had two steps in my pipeline a 'build and test' step and a 'deply to docker' step where i tried to copy the artifacts to the docker image. To pass the artifacts to from the 'build and test' step to the 'deply to docker' step I had to add this to the first step

artifacts:
- target/**

For more information see:

https://support.atlassian.com/bitbucket-cloud/docs/use-artifacts-in-steps/

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events