Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

1 vote
Answer accepted

Adding the following resolved this:

 

artifacts:
- target/**

Hi lee,

 

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

Like veselinnguyen likes this

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

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
Community showcase
Published in Bitbucket

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

3,927 views 10 16
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you