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.

[plugin] Evaluating script from parent build #3853

kururin ·

Hello

Here is our context:

  1. Conf_A triggers Conf_B and passes a variable V1 to Conf_B through the triggered step
  2. Conf_B uses V1 in its build description. Say the description is: "build_B is ${vars.getValue("V1")}"
  3. With a plugin (Tab plugin), from Conf_A we get the description of Conf_B steps. The problem is that the description is not properly evaluated. At the end we get: "build_B is ". The V1 value is missing.

We guess it's because Conf_A does not know the Context of Conf_B so V1 is unknown.

Here is a part of the code of our plugin:

public  ArrayList GetErrors(Build b)
{
	GetErrorsInternal(b);
	return errors;
}

private void GetErrorsInternal(Build b)
{
	for(Step s : b.getSteps())
	{							
		if(s.getClass().getSimpleName().contains("TriggerBuildStep") && s.isFailed())
		{	
			Build TriggeredBuild = Quickbuild.getInstance().getBuildManager().load((Long) s.getRuntime().getCustomData());				
			GetErrors(TriggeredBuild);
		}
		else
		{
			if(s.isFailed() && !s.getErrorMessage().contains("success condition"))
			{										
				String description = s.getDescription(); // problem HERE. Description is not evaluated.

So from build_A, we get description of build's steps that have been triggered.
We tried many things (altering the Context, using "DefaultScriptEngine.instance.evaluate" to evaluate the description from another Context, etc.) but we never managed to get the correct description...

Would you have any suggestion?

Thanks a lot
Mathieu

  • solved #2
  • replies 2
  • views 3075
  • stars 0
robinshen ADMIN ·

Please try below to see if it works.

import com.pmease.quickbuild.Context;

public  ArrayList GetErrors(Build b)
{
    Context.push(b);
    try {
        GetErrorsInternal(b);
        return errors;
    } finally {
        Context.pop();
    }
}
kururin ·

You're my hero. It works like a charm :)
Thanks a lot Robin.