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 list of all used steps in a configuration tree #54

tomz ·

I'm trying to get a list of all steps used in a configuration tree in a quickbuild script but I'm struggling to find the right APIs to do this.

What I'm trying to do to get the steps in a config:

Set<String> sortedStepNames = new TreeSet<String>(); 
myConfig = Quickbuild.getInstance().getConfiguration('path/to/config');
masterStep = myConfig .findStep(com.pmease.quickbuild.stepsupport.Step.MASTER_NAME);
compositeStep = masterStep as CompositeStep;
addChildrenToList(compositeStep, sortedStepNames);

def addChildrenToList(compositeStep, sortedStepNames)
{
  children = compositeStep.getChildren();
  for (Step s : children)
  {
    synchronized(this)
    {
      stepNames.add(s.getName());
    }
    if (s instanceof CompositeStep)
    {
      addChildrenToList(s, stepNames);
    }
  }
}

But this is always failing with Exception: The step is not associated with any build.
What's the proper way to find all steps defined and used in a configuration tree. This will also help immensely if I can then delete all unused steps, as it could save me a great deal of time on the diffs.

Thanks in advance,
Tom Z.

  • replies 1
  • views 1453
  • stars 0
robinshen ADMIN ·

step.getChildren() should only be used during the build of corresponding configuration. Please use below script instead:

groovy:

import com.pmease.quickbuild.stepsupport.CompositeStep;

Set<String> sortedStepNames = new TreeSet<String>(); 
myConfig = system.configurationManager.get('root');
addChildrenToList("master", sortedStepNames);

def addChildrenToList(stepName, sortedStepNames)
{
  sortedStepNames.add(stepName);
  step = myConfig.findStep(stepName);
  if (step instanceof CompositeStep) {
    for (childStepName in step.childStepNames) {
	  addChildrenToList(childStepName, sortedStepNames);
	}
  }
}