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.

Creating Variable Choice List Using User Attributes #80

tscholl ·

Trying to create a variable that will populate with choices based on a set of user attributes.

Purpose would be to create a list of nodes that a job could run on and let the user chose which ones actually get run without manually defining an agent list every time, especially since our agent names seem to change a bit whenever a box restarts.

I know Groovy has this power but a bit of a noob with it still? Anyone already have something like this and can share?

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

I guess you want to populate choices with all build agents matching specified user attribute value? If so, please use below for variable choices field:

${groovy:
def matchingNodeAddresses = []
for (eachNode in grid.allNodes) {
  if (eachNode.userAttributes["someAttribute"] == "someValue")
    matchingNodeAddresses.add(eachNode.address);
\}
return util.join(matchingNodeAddresses);
}
tscholl ·

Perfect, Thanks Robin.