Skip to main content



      Home
Home » Archived » Hudson » How to evaluate label expressions in a Builder?
How to evaluate label expressions in a Builder? [message #1693297] Wed, 22 April 2015 23:08 Go to next message
Eclipse UserFriend
I'd just like to implement automatic tool installation selection by label expressions in a Builder class, in which a tool installation would be implicitly selected if the label expression associated to it evaluates to true.

Is there any easy way to evaluate label expressions in a Builder? If any, how can I use it?
Re: How to evaluate label expressions in a Builder? [message #1693982 is a reply to message #1693297] Wed, 29 April 2015 14:09 Go to previous messageGo to next message
Eclipse UserFriend
In Hudson a "label" means a tag given to a slave to indicate one of its capabilities. So multiple labels are allowed. A label expression is an expression that evaluates to select a slave based on combination of capabilities. For example label expression "linux && jdk8" means nodes that are linux based and has jdk8 installed. How do you plan to use label expression in a Builder?
Re: How to evaluate label expressions in a Builder? [message #1693998 is a reply to message #1693982] Wed, 29 April 2015 20:53 Go to previous messageGo to next message
Eclipse UserFriend
I am planning to assign a label expression to each tool installation and to make it selected automatically according to the label axis so that several tool versions can be scattered to multiple nodes.

For example,
node A has tool versions X and Y with labels X and Y,
node B has tool versions Y and Z with labels Y and Z, and
I want to run a builder once for each tool version by selecting labels X, Y, and Z in the label axis.

Is it possible to use label expressions for such a thing? Or do I need to use Groovy expression instead?
Re: How to evaluate label expressions in a Builder? [message #1694124 is a reply to message #1693998] Thu, 30 April 2015 13:48 Go to previous messageGo to next message
Eclipse UserFriend
Hudson uses LabelExpression something like the following

String labelExpression = .. ;
Label labelTree = Label.parseExpression(labelExpression);
Set<Node> nodes = LabelTree.getNodes();


Then uses suitable node to schedule the building.

I think in your use case Groovy expression may be appropriate. Something like

String groovyExpression = "..";

            Map<String, Object> variableMap = new HashMap<String, Object>();

            variableMap.put("variable1",  ..);
            variableMap.put("variable2",  ..);
            Object result = Hudson.getInstance().getScriptSupport().evaluateExpression(expression, variableMap);


Re: How to evaluate label expressions in a Builder? [message #1694156 is a reply to message #1694124] Thu, 30 April 2015 21:15 Go to previous message
Eclipse UserFriend
Thank you for the information and suggestion. One thing I'm afraid of is the label variable name can be anything per job, so I cannot assign an expression such as 'label == "X"' to tool installation X beforehand.

Alternatively, can I define a new matrix axis that can choose nodes by something like a label expression? What I'd like to do is not to choose nodes to run a job directly but indirectly by installed tool versions. If I could specify tool versions X, Y, and Z in a new axis and appropriate nodes could be chosen automatically for each, it would be much better.
Previous Topic:Hudson error 500
Next Topic:Unable to show latest console output
Goto Forum:
  


Current Time: Wed Jul 23 15:12:28 EDT 2025

Powered by FUDForum. Page generated in 0.33886 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top