I have currently java application which has the database.properties file for storing the connection string, user & password.
Instead of storing these details in the bitbucket repository i would like to use the environment variables.
How would i do this using the Bitbucket pipeline or Bamboo ?
It is difficult to understand what part of this process you are looking for just from your question. Do you want to know how to declare the variables, how to consume them in the JAVA application, how to run the declare password variables...?
Regarding the variables for Bamboo, I encourage you to check this document:
Regarding Pipelines ones, please check this one:
You will need to choose where is the best location to store the variable you need.
If you are looking for tips on how to load the variable data into your JAVA application through a script or terminal, then I think this is not the ideal forum. I would encourage you to drop this question on a JAVA specific one.
I hope I could help.
My first question is instead of storing the database connection string , user name & password in bitbucket, how can i use the environment variables so that i do not have to change the config file when i moved from dev to staging to prod ?
My second question is should i be using environment variables provided in bamboo or use the variables in the bitbucket pipelines as both do provide the option to use environment variables ?
Let me share how I see you could do this for Bamboo. A similar solution could be used in case you are deploying your project using Pipelines.
I was a little bit confused because I was considering that you were talking about two different solutions, one for Bamboo and another for Pipelines. I'm now thinking that you are only using Bamboo connected to Bitbucket and considering that Bitbucket Pipelines variables could be used in Bamboo. Am I correct?
Thanks for providing the details.
I am currently using both bitbucket & bamboo for the entire devops CI/CD.
I would like to know for my case if i need to use the environment variables within Bitbucket or Bamboo for the storing the connection string details.
Also how would my application (Java or .net) read the bamboo/bitbucket environment variables, i could not find any sample case studies or sample code showing the same.
If you are running Pipelines builds you need to use Bitbucket variables, if you are using Bamboo builds you need to use Bamboo variables. You need to have the variables set in the same build environment running. You cannot use Bamboo variables in Bitbucket Pipelines or vice-versa.
Regarding the way to read the variables, as I shared before, that is a matter of JAVA or .net technology that is not related to Bamboo or Bitbucket. You will need to research this specifically on other channels. I've just run a search for this and found a thread in stack overflow for the JAVA case: Can we read the OS environment variables in Java? - Stack Overflow.
The variables will be available in the build environment when the application is running or when the compilation is running. You will need to seek methods to read them that will be handled by the tool you are using at that moment. For instance, anything that works in the OS terminal should work under Bamboo as well.
Hi, If you are running self-managed environments and looking to adopt modern infrastructure, Bamboo Data Center can now be deployed in a Kubernetes cluster. By leveraging Kubernetes, you can easily...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events