How do I store settings per plan in a repository plugin?

I can't seem to find a way to get the plan key from prepareConfigObject:

public void prepareConfigObject(@NotNull BuildConfiguration buildConfiguration) {


I need to store specific configuration items for a repository plugin I'm creating per plan. It's unlikely the same repo settings will be used for every plan.

What I actually need to store is a configuration file per plan. This has to be done as a file and can't be done using the configuration.setProperty mechanisms. I've tried getting the base working directory, but that only takes me to the build-dir directory:

File parentDirectoryFile=this.buildDirectoryManager.getBaseBuildWorkingDirectory();
String parentDirectory=parentDirectoryFile.getAbsolutePath();
String workingDirectory=parentDirectory+File.separator+this.getShortKey();
 File f = new File(workingDirectory+"/config.txt");

I need access to the plan directories under build-dir so I can store settings per plan. I don't know, maybe I'm going about this the wrong way. Any input is greatly appreciated.

1 answer

1 vote

Settings per plan: buildConfiguration object is already per-plan, i.e. whatever you store in it or retrieve from it will be for specific plan.

Accessing build directory: If you have access to BuildContext, you should access the build directory with .

If you don't have access to it, I'd need to know more about your use case.

I'm working a thrid party authenticator, which requires a file handle as a parameter, and the AbstractStandaloneRepository class. WHen you store your settings in the repository settings tab under your plan, prepareConfigObject get's called, then validate. BuildContext is not accessible from within this method. I need to create this file handle somehow so it's saved per plan. RIght now, I can store in a separate directory under build-dir, but when I setup a new plan, this will get overwritten. I need to have this file saved per plan. I wish the authenticator didn't work this way, and only took the ssh private key as string, but it has to have a file :(

Working directory is not your only problem - change detection will need to authenticate too.

Why not have a separate directory with your authentication files?

Currently, I'm trying to create a separate directory for this purpose, or at least one nested in the build plan directory. There's no guaruntee they will use the same key for every plan as projects vary. Do you have an example in mind?

The problem is that during change detection you will not have a build directory because the build has not yet started (and potentially won't start). You need to have a yet different directory.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Jan 15, 2019 in Statuspage

Introducing Statuspage Getting Started guides! First up: What is Statuspage?

Over the next several weeks we'll be sharing some of our Getting Started guides here in the community. Throughout this series of posts, we'd love to hear from customers and non-customers ab...

304 views 5 2
Join discussion

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