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.

Copy Configuration as Step #3463

jmash ·
Greetings,

I have a case where I would like to be able to copy an existing configuration as a new configuration, with a new name and a couple of updated variables. I've tried using the 'Sync Configurations' build step as well as a scripted method using the ConfigurationManager, however they both appear to cause the QB server to become unresponsive (I let them run for 20+ minutes).

Is this an expected amount of time to clone an existing configuration? Is there a better method to do this, or should it be avoided?

Thanks,
-J
  • replies 11
  • views 3066
  • stars 1
jmash ·
I can replicate this behavior on a completely clean server install (6.1.2, 6.1.4, and 6.1.6) using the example 'Sync Configurations' task, as well as using the ConfigurationManager to copyAsNew/save script to clone a configuration under a new name. I've verified all three of the versions noted on both Mac OSX 10.10 and Ubuntu 14.04.03, all with the same results.

I suspect this may be a bug and am curious if it occurs for you guys as well?

Thanks,
-J
robinshen ADMIN ·
I guess you are syncing the whole configuration tree including all descendeant configurations? If it contains many many configurations, it may take some time to run. Also you may check the system log to see at what point it is stuck at:
Syncing '<configuration name' from ...
jmash ·
I am not attempting to copy/sync the entire configuration tree, rather just a single configuration with no children, no custom build steps (all are inherited from the parent), and only three overridden variables. The goal I have is to simply create a copy of an existing configuration as a sibling configuration with a different name, and then to update the values of the variable overrides as appropriate.

The first attempt at doing that was to use the ConfigurationManager to copyAsNew, change the name, and then save the new configuration, but that caused QB to freeze and become unresponsive. The second attempt was to use the 'Sync Configurations' build step to do it, but I ran into the same issue there. In both cases, the last line of the server log was something along the lines of this:

jvm 1 | 2016-03-06 13:47:41,700 INFO - Checking build condition on node (address: ..., ip: ...)...
jvm 1 | 2016-03-06 13:47:41,800 INFO - New build version is calculated as '1.0.2'.

That log was from me standing up a fresh, bone stock QB instance and simply running the 'root/~maintenance/sync configurations' task to try and copy 'root/~maintenance/copy promotions' configuration as 'root/~copy/copy promotions'. I've made no modifications to that instance, and the result is identical to what I experience in my actual server.

I can send the DB if that helps, but I'd imagine you can replicate it the same way I did. Let me know how I can help or if you need more information.

Thanks,
-J
robinshen ADMIN ·
Thanks this is indeed a QB bug, and will happen with the embedded h2 database (although not suggested for production use). It is now fixed in below build:
https://build.pmease.com/build/2980
jmash ·
Confirmed the fix with both methods of cloning a configuration -- thanks for the extremely quick turnaround on this!

-J
HealingQuickly ·

Hi there jmash. How did you copy existing config with a new name, through groovy script? I've tried using the sync config step, and there's not a way to change the name of the new config. I had a variable for the new config, but it always uses the default value of that variable

Please help
Thank you!

robinshen ADMIN ·

Below script will do the work:

groovy:

def existingConf = system.configurationManager.get("path/to/existing/conf")
def copiedConf = system.configurationManager.copyAsNew(existingConf, false)
def newParent = system.configurationManager.get("path/to/new/parent")

copiedConf.parent = newParent
copiedConf.name = "new name"
system.configurationManager.save(copiedConf);
robinshen ADMIN ·

To copy configuration recursively:

groovy:

import com.pmease.quickbuild.persistence.SessionManager;

SessionManager.openSession();
try {
  def existingConf = system.configurationManager.get("path/to/existing/conf")
  def copiedConf = system.configurationManager.copyAsNew(existingConf, true)
  def newParent = system.configurationManager.get("path/to/new/parent")

  copiedConf.parent = newParent
  copiedConf.name = "new name"
  system.configurationManager.save(copiedConf, true);
} finally {
  SessionManager.closeSession();
}
robinshen ADMIN ·

Forget to mention that to make this script working, you will need upgrade to QB 7.0.23

ribeiromauro ·

Hey Robin,

Thanks for the code above. I have one question though. In "Execute Script" steps, some internal objects from Quickbuild are always available, like: configuration, system, logger, etc...

While coding as a separate jar plugin, what would be the equivalent call to them ?

Something like:

On groovy ----------------------------- Inside external jar that is a QB plugin
logger ----------------------------- Context.getLogger()
system ----------------------------- ?
configuration ------------------------- Context.getConfiguration() or Quickbuild.getCacheManager().getConfigurations() or ?

I'm asking this as some1 who trying to do what the code above does, but packed in a plugin instead of a step.

Thanks and Regards,
Mauro

robinshen ADMIN ·

com.pmease.quickbuild.Context will contain context of current executing builds, such as logger, build, configuration, etc. The system object can be retrieved by calling QuickBuild.getInstance().