Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Hudson » How to evaluate label expressions in a Builder?
How to evaluate label expressions in a Builder? [message #1693297] Thu, 23 April 2015 03:08 Go to next message
Kaz Nishimura is currently offline Kaz NishimuraFriend
Messages: 89
Registered: December 2014
Member
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?


Kaz Nishimura
Re: How to evaluate label expressions in a Builder? [message #1693982 is a reply to message #1693297] Wed, 29 April 2015 18:09 Go to previous messageGo to next message
Winston Prakash is currently offline Winston PrakashFriend
Messages: 534
Registered: August 2011
Location: Fremont, CA USA
Senior Member
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?

Winston Prakash
Eclipse Hudson team
Re: How to evaluate label expressions in a Builder? [message #1693998 is a reply to message #1693982] Thu, 30 April 2015 00:53 Go to previous messageGo to next message
Kaz Nishimura is currently offline Kaz NishimuraFriend
Messages: 89
Registered: December 2014
Member
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?


Kaz Nishimura
Re: How to evaluate label expressions in a Builder? [message #1694124 is a reply to message #1693998] Thu, 30 April 2015 17:48 Go to previous messageGo to next message
Winston Prakash is currently offline Winston PrakashFriend
Messages: 534
Registered: August 2011
Location: Fremont, CA USA
Senior Member
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);




Winston Prakash
Eclipse Hudson team
Re: How to evaluate label expressions in a Builder? [message #1694156 is a reply to message #1694124] Fri, 01 May 2015 01:15 Go to previous message
Kaz Nishimura is currently offline Kaz NishimuraFriend
Messages: 89
Registered: December 2014
Member
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.


Kaz Nishimura
Previous Topic:Hudson error 500
Next Topic:Unable to show latest console output
Goto Forum:
  


Current Time: Wed Oct 09 16:33:02 GMT 2024

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

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

Back to the top