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

This widget could not be displayed.

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 Sign up to answer
Community showcase
Published Aug 21, 2018 in Bitbucket

Branch Management with Bitbucket

As a project manager, I have discovered that different developers want to bring their previous branching method with them when they join the team. Some developers are used to performing individual wo...

1,619 views 9 11
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