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

1 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!



Hello, solution 1 works, but adds the overhead to rebuild common each time we want to build a repo which depends on it. But it works so thanks for that.

For solution 2, I don't manage to make it work, but more importantly I don't understand how it could work. When building main app, from where is the common dependency going to be "downloaded" ? I don't see how using the release plugin is putting the common stuff anywhere usable by the main app.

For solution 2 this is what you have to do for configuring properly the maven release plugin:


Add to the pom:

































<name>Spring Milestones</name>


























and the pipeline for your common project should be:


image: maven:3.3.9



    - step:


          - maven


          - mvn -B clean deploy


for the other project you can do mvn clean install only

Like 1 person likes this

Ok thanks, I understand better now, so basically the common artifact once built will be stored in mymavenrepo.com or any equivalent service, and then when building the main, it'll simply download the dependency from there.

I guess this works as well for private repos for which you don't want your artifacts to be exposed publicly.

As for my own use case, I ended up cutting the dependency between my two repos to make it simpler.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Thursday in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder

...ipe.sh :  #!/bin/bash source "$(dirname "$0")/common.sh" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

225 views 0 12
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