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.

get names of all steps in a configuration #3327

zoywiki ·
I want to get a name of all steps contained in the master step for the current configuration via groovy script and print them out.

Can you point me to the correct direction in accomplishing this?
  • replies 7
  • views 3579
  • stars 0
robinshen ADMIN ·
Pseudo code as below, and you will need to adapt to groovy grammer:

var referencedSteps = [];
var masterStep = configuration.findStep("master");
referencedSteps.add(masterStep);
fillReferencedSteps(masterStep, referencedSteps);

function fillReferencedSteps(step, referencedSteps) {
if (step instanceof CompositeStep) {
CompositeStep compositeStep = (CompositeStep) step;
for (String each: compositeStep.getChildStepNames()) {
step = configuration.findStep(each);
if (step != null && !referencedSteps.contains(step)) {
referencedSteps.add(step);
fillReferencedSteps(step, referencedSteps);
}
}
}
zoywiki ·
Thanks. Got this working with your pseudo code.

In case anyone else ends up looking for this here is the code


groovy:
import com.pmease.quickbuild.stepsupport.CompositeStep;

def buildConfigPath = "root/path/to/your/config";

def buildConfiguration = system.getConfiguration( buildConfigPath );
def referencedSteps = [];
def masterStep = buildConfiguration.findStep("master");

referencedSteps.add(masterStep);
fillReferencedSteps(masterStep, referencedSteps);

def fillReferencedSteps(step, referencedSteps)
{
if (step instanceof CompositeStep)
{
CompositeStep compositeStep = (CompositeStep) step;
for (String each: compositeStep.getChildStepNames())
{
step = configuration.findStep(each);
if (step != null && !referencedSteps.contains(step))
{
referencedSteps.add(step);
fillReferencedSteps(step, referencedSteps);
}
}
}
}

// if you want to remove the master step from the list steps
// referencedSteps.remove(0);

for (i in referencedSteps)
{
logger.info( i.getName() );
}
robinshen ADMIN ·
Thanks, I posted this to scripts/plugins sub forum in case other one need it.
Laba42 ·

I have the following configurations: root/child-1/child-2/child-3
and in each, except for the last configuration, I created a step.
In Configuration "Child-1" i add the step from root and the step created in Child-1 to the workflow
In Configuration "Child-2" i added the step, created in this configuration, to the workflow.
in the last configuration "child-3" the workflow looks like:

master
  step-root
  step-1
  step-2

Based on the script above and here in the forum I wanted to create a list of the used steps of a configuration.
If I execute the script for the configuration root/child-1/child-2/child-3 only the step-root is listed.

16:09:43,897 WARN - Steps: master
16:09:43,897 WARN - Steps: step-root

Why are not all steps of the configuration shown?

Georg

zoywiki ·

sounds like master step of root/child-1/child-2/child-3 is overwritten or inherited incorrectly somewhere in your chain.

robinshen ADMIN ·
Laba42 ·

Thank you, that's exactly what I wanted.:thumbsup: