Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to specify different databases for different build plans in Bamboo?

Adrian Muresan April 21, 2020

I have a test and a prod environment build plan. The Prod works while the Test, although is configured exactly the same, doesn't. 

They both pull from the same master branch, have a Maven set-up, and normally, connect through the databases (there is one for each one) specified in the pom.xml file. 

I want to make sure that each build plan hits the same database. How do I do this? Maybe it's something that it's overriding the pom.xml file ?

What else could work two build plans with identical configuration to behave differently ? One runs while the other doesn't. 

1 answer

0 votes
Lasse Langhorn
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 21, 2020

Hi,

 

If I were to define a setup like this I would use system properties in my Maven goal for the Maven 3.x task.

For this task you must set the Maven goal where it is possible to define system properties as well.

You can have a Maven goal like this for PROD:

clean install -U -Ddb.user=prod_user -Ddb.password=prod_password -Ddb.url=jdbc:postgresql://localhost/prod

You can have a Maven goal like this for TEST:

clean install -U -Ddb.user=test_user -Ddb.password=test_password -Ddb.url=jdbc:postgresql://localhost/test

You can also define Bamboo variables in your build scripts: Passing Bamboo variables to a build script 

Then in your Maven project you can use these system properties with property substitution for example in your app.properties file

database.user=${db.user}
database.password=${db.password}
database.url=${db.url}

Hope this will give you an idea on what can be done.

Regards

Lasse Langhorn

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events