maven build pipeline always download dependencies



I'm using for the first time the pipeline feature in, and I'm surprised to see that for each build triggered by new commits, maven always download dependencies, even if they were previously downloaded in another build.


Is it a bug or not ?



2 answers

0 votes

This is an expected result of Bitbucket Pipelines build environments being comprised of ephemeral Docker containers that run automatically after each code push. That is, for each build a new Docker container is launched, and then terminated at the end of the build, which implies that all non explicitly managed files (like the cached Maven artifacts at hand) only live as long as the container itself.

This 'build from scratch' behavior is usually highly desired to guarantee that builds are completely isolated from each other. The obvious downside is that any form of build time and resource usage optimizations like caching dependencies does not work out of the box.

To facilitate those optimizations regardless, you can create custom Docker images and use these tailored build environments instead of the default ones. So for the scenario at hand you might want to create a container image that has those Maven dependencies downloaded already - of course, such tailored images should ideally be maintained via CI/CD as well, and while Bitbucket Pipelines itself cannot yet build Docker images, Bitbucket still offers an indirect approach for this via Docker Hub as outlined in Configure automated builds with Bitbucket (beware that this has nothing to do with Pipelines at all).

For all the people dropping by currently, please note that Atlassian now supports caching dependencies via the "cache" directive in the piplelines yml file. Refer to

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

1,910 views 7 10
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you