Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

change repository settings using JAVA API #4313

OnQuickBuild ·

Hi Robin

Is there a repository method that can change its settings dynamically after a build starts? Something like using a script step before the repository is used.
I checked the Java doc for "com.pmease.quickbuild.repositorysupport.Repository " class, and there isn't a setter method that seems to be able to change its settings that are provided in GUI. For example, if the repo type is QB, I'd like to use a script to access the repo object, change its "build" from "latest successful" to a specific build version, etc. Or even change the configuration path for the QB repo, so that I don't have to use GUI, and the changes can happen dynamically.

Is this possible right now?

I understand before a build starts, QB checks if the repos can be referenced successfully. So it seems it'll be too late to change the repo settings once the build has started.

Thank you!

  • solved #7
  • replies 6
  • views 2586
  • stars 0
OnQuickBuild ·

Take QB repo for an exmaple. To change the configuration path, maybe I can place a variable there in GUI, then I can change the variable value after the build starts. Is this gonna work?

And to change which build of the QB config to checkout from, all options are drop down menus, the only place that allows a variable is "specify a build version". Can this work as well?
And what if I want to use the latest successful build when the setting is "specify a build version"? I just wonder if there are APIs that provide this kind of flexibility.

Thank you!

robinshen ADMIN ·

A QB repo has setter method to change various properties including configuration path and build version. For instance:

groovy:
import com.pmease.quickbuild.dependency.*;
def repo = configuration.findRepository("repo name");
def configurationProvider = new SpecifiedConfigurations();
configurationProvider.setConfigurationPaths("root/conf1");
repo.setConfigurationProvider(configurationProvider);
def dependencyResolver = new SpecifiedBuildResolver(repo);
dependencyResolver.setBuildVersion("1.0.0");
repo.setDependencyResolver(dependencyResolver);
system.configurationManager.saveRepository(configuration, repo, null);
OnQuickBuild ·

How to switch between a specific build version to "latest successful"?

robinshen ADMIN ·

Use below instead:

def dependencyResolver = new LatestSuccessfulResolver(repo);
repo.setDependencyResolver(dependencyResolver);
OnQuickBuild ·

Hi Robin

This didn't work for me in a number of ways:
I have a QB repo and I cannot leave the settings blank. Because if I do, before the build starts, it will already fail saying "referenced repo not found". And since I'm trying to use this script to change the configuration properties, I still have to leave some valid values in the GUI settings, or else the build will fail before it starts.

Then I give the GUI setting a valid config path, and the "build" setting to "latest successful". Because I was hoping to use the script to change the build property from latest successful to a specific version. I used this script (in the checkout step, in its pre execution action: execute a script"), and it still ends up checking out the latest successful artifacts from the QB repo.

How exactly should I use this script?
My intention is to use a JSON file to control these build properties of a configuration, including its repositories.
And obviously the JSON file can only be dynamically accessed when the build already started, and it seems Quickbuild pins down the repo properties before it starts.

Thanks!

robinshen ADMIN ·

It can not be changed dynamically during a build unfortunately. I was thinking you want to change it for next build.