maven build pipeline always download dependencies

Hi,

 

I'm using for the first time the pipeline feature in bitbucket.org, 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 ?

 

Regards,

2 answers

0 vote

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).

0 vote

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 https://confluence.atlassian.com/bitbucket/caching-dependencies-895552876.html.

Suggest an answer

Log in or Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

701 views 0 4
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot