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.

Run all child configurations #2167

minic ·
Hi,

I have a simple question.
If I start a parent configuration, I would like to have an easy way to trigger/run all child configurations of this parent, also.

In other words: How do I chain different configurations to run one after the other?

I do not want to add a "Trigger other builds" step for each child of the parent configuration.

Any clue?

Thanks in advance,
Michael
  • replies 13
  • views 4948
  • stars 0
burshtei ·
Hi,

You can set the parameters in avdance setting of "Trigger other configuration" step to get all child of current configuration somthing like :
 configuration.getChildren().each{it-> it.getPathName() + ","}
, and use the parameter in "Configuration" field e.g.
parameters.get("child")
.
minic ·
Hi,

thanks for the quick reply.

That's almost what I wanted.
If one child config is disabled, the whole build process stops:

master
Composite step 'master' failed due to unsatisfication of success condition.

master>1-Run all children?child=root/myParent/Child2
Step is failed since the triggered build is failed, cancelled, or timed out.

I would have assumed that a disabled child config is simply ignored, but that's not the case.
Any advice on this?

Greetings,
Michael
robinshen ADMIN ·
You may skip the disabled child when concatenating the child params, disabled child config can be checked with "child.isDisabled()"
minic ·
Hi,

can you please help me with this?
How do I create a script which concatenates all child configs of a parent config?

According to the manual, the "configuration" object does not have a "getChildren()" method, only a "getChild(string)" method.
How do I iterate over all children of a configuration?


I tried this, but it does not work:

${
result = "";
foreach (child : configuration.getChildren()){
if (!child.isDisabled()){
result = result + child.getPathName() + ",";
}}}


Failed to evaluate below expression:
mvel:
result = "";
foreach (child : configuration.getChildren()){
if (!child.isDisabled()){
result = result + child.getPathName() + ",";


Thanks,
Michael
burshtei ·
Are you sure that concatanate strings with + oparetor is legal ? Try to write

groovy:

before.
robinshen ADMIN ·
The configuration does have a getChildren() method, and sorry we forget to document this. I rewrite your script with below version which should work:

${groovy:
result = "";
for(child in configuration.getChildren()){
if (!child.isDisabled()){
result = result + child.getPathName() + ",";
\}
\}
}
minic ·
Hi,

thanks for your reply.

I have copied&pasted your script, but when I try to run it I get the following error:

org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.pmease.quickbuild.model.Configuration.children, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:383)
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:375)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:368)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:111)
at org.hibernate.collection.PersistentBag.iterator(PersistentBag.java:272)
at java_util_List$iterator.call(Unknown Source)
at script13612606494401881127451.run(script13612606494401881127451.groovy:3)
at com.pmease.quickbuild.plugin.basis.BasisPlugin$20.evaluate(BasisPlugin.java:277)
at com.pmease.quickbuild.DefaultScrip...


Any hints?

Greetings,
Michael
robinshen ADMIN ·
Looks like the script is evaluated in background build instead of web GUI. To avoid this error in this case, please use below version instead:
${groovy:
result = "";
for(child in system.configurationManager.getChildren(configuration)) {
if (!child.isDisabled()){
result = result + child.getPathName() + ",";
\}
\}
}
minic ·
Hi,

to actually work, the script has to look like this:
${groovy:
result = "";
for(child in system.configurationManager.getChildren(configuration)) {
if (!child.isDisabled()){
result = result + child.getPathName() + ",";
\}
\}
result = result;
}


The last assignment is neccessary, otherwise the return value of the script is empty.

Thanks very much for your help.

Greetings,
Michael
robinshen ADMIN ·
You are right.
Or just return the result via "return result"
jgeorgeson ·
I'm probably missing why you can't use this, but in 4.0.90 there's a built-in Repeat Parameter value of "Paths of all child configurations".
minic ·
Hi,
that parameter is still there, no question about that.
Problem is, that the resulting list contains all child configs, even those which are disabled.
If you try to run a disabled config automatically, QB throws up (see my post above).

Greetings,
Michael
nmanos ·
Nice solution.
What if I want to do it recursively - trigger all children AND grand-children, and grand-grand-children (those whose enabled only) ?

This is non-recursive but includes grand-children:

${groovy: 
result = "";
for(child in system.configurationManager.getChildren(configuration)) {
if (!child.isDisabled())
{ result += child.getPathName() + ",";
\}
for(grandchild in system.configurationManager.getChildren(child)) {
if (!grandchild.isDisabled())
{ result += grandchild.getPathName() + ",";
\}
\}
\}
return result;
}


Thanks,
Noam.