'Reference bamboo variable in Java code

I have java app being built and deployed through Bamboo. Is there way to populate, or insert into, java variable from bamboo deployment variable?

If something like below could work, is there additional steps that needs to be done within Bamboo configuration, or even within Java manifest file?

String myVariable = "${bamboo.myVariable}";

[Bamboo Deployment Variable Configuration Screen]



Solution 1:[1]

If your custom variable is as myVar and bamboo default variable as bamboo.buildNumber, then they should be called as below.

Inside Bamboo Job ==> ${bamboo.myVar} and ${bamboo.buildNumber}

Inside Java Code ==> String myVal = System.getenv("bamboo_myVar"); and String buildNum = System.getenv("bamboo_buildNumber");

Hope this simple and helps

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1