Pipeline - build depends on another development package in a different repo

How do i setup and build a dependency maven package within a pipeline.


I would like to create a pipeline to build(maven) a new java app package but this package depends on another 'common' package held in a different bitbucket repo.

Within my local development environment the build process is straightforward 

step 1. within common package folder run : mvn clean install

step 2. within the new java app package run : mvn clean package

This successfully places the common jar file into local maven repo and is available during the build of the new java app.


How do I perform similar steps in a pipeline? Do I assume that I will have a local maven repo in the docker image during the build pocess?


Thanks for your help

1 answer

0 vote

Hi Patrick,

I have two possible solutions for you here.


First option. If you want to replicate what you are doing on your own machine, you will need to clone the common package into your pipeline as well. As we will only clone the main java application repository.

You'll need to set up access keys and ssh keys for your repository and pipelines:

You'll then want something like the following in your bitbucket-pipelines.yml for your main java repository:

image: java:8
- apt-get update -y
- apt-get install -y git
- git clone git@bitbucket.org:username/common.git
- cd common
- mvn clean install
- cd ..
- mvn clean package
- # Whatever else you need.


Second option. If you want a more idiomatic pipeline, you can instead have two pipelines. One to build you common package and one to build you main java repository.

You will need to configure your common package to have the maven release plugin: http://maven.apache.org/maven-release/maven-release-plugin/

This will allow you to release the common package as its own package, which you can then use as a regular dependency in your main java repository.

In your common package, once configured in the pom.xml properly, your pipeline should look like:

image: java:8
- mvn clean package
- mvn release:prepare
- mvn release:perform

And then in your main java application repository, your pipeline will simply look like

image: java:8
- mvn clean package
- # Whatever else you need.

Hope this helps!



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

714 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