Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to access path of a file in bamboo working directory using JAVA code

V gopi
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 31, 2023

Hi, I am currently in need of reading a file path which is present in bamboo build working directory. This is how i am doing currently. but im not able to get the path

bamboo variable.png

Can you help me to resolve this?

1 answer

1 vote
alok m April 12, 2024

The snippet of code you've provided seems to be attempting to open a KeePass database file by constructing a file path that includes a system property for the Bamboo build working directory and a relative path to the KeePass file. Here's a breakdown of what the code does:

  1. System.getenv("") tries to access an environment variable named which is expected to hold the path to the Bamboo build working directory.
  2. It then appends "\Temp\KEEPPASS\mongodb.kdbx" to this path, which is the relative path to the KeePass file you want to access.
  3. The .openDatabase("remove&credentials@1527"); method is then called with a passphrase.

If you are not able to get the path, there might be a few reasons:

  • The environment variable might not be set or could be incorrect.
  • There may be a typo or a mismatch in the case of the environment variable name.
  • The file path may not be correct, or the file might not exist at the specified location.
  • File permissions might be preventing access to the file.

To debug this issue, you could add logging to print out the constructed file path before trying to open the database. This way, you can verify whether the path is correct. Here's an example in Java:

String workingDirectory = System.getenv("");

String filePath = workingDirectory + "\\Temp\\KEEPPASS\\mongodb.kdbx";

 System.out.println("The constructed file path is: " + filePath);

 // Now proceed to open the database with this file path

KeePassFile database = KeePassDatabase.getInstance(filePath)



Make sure the KeePass file exists at that path and that the application has the necessary permissions to access it.

If the environment variable isn't set, you may need to check your Bamboo configuration to ensure that it is being passed to your build environment correctly. Alternatively, if the Bamboo build working directory follows a consistent structure, you might be able to construct the path based on known values instead of relying on an environment variable.


Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events