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.

Schedule build on resource only if it exists (QB 8.0.7) #4041

eranbb ·

Hi
We have a configuration that accepts a variable with a name (lets call is X). This name may be resource name or node name.
We are trying to schedule a build with one of 2 conditions:

  1. Node with resource == X.getValue()
    OR
  2. Node with hostName == X.getValue()

The problem is, in case we use the node name and there is no resource with this value, the first condition throws exception. We must use an existing resource name although the second condition is valid.

Any idea how we can overcome this issue?

Thanks in advance

  • replies 5
  • views 852
  • stars 0
robinshen ADMIN ·

Change condition1 to use below script should work:

import com.pmease.quickbuild.entitymanager.*;

ResourceManager.instance.get(X.getValue()) != null && node.hasResource(X.getValue());

The resourcemanager is used to check if resource is defined

eranbb ·

Thanks for the fast response!
I assume that this script should be in "On node with specified script evaluating to true" condition.
In this case, will it consume the resource?

This is what we currently use (which throws exception in case testResource is a node name and not a resource name)

sched.jpg Thanks
eranbb ·

I see that it failed to upload the image... Will write it as text

  • On node matching one of the specified criterias
    • On node with specified script evaluating to true
      • groovy:
        if (node.getHostName().equals(vars.getValue("testResource"))){
        return true;
        }
        return false;
    • On node with specified resource
      • ${
        groovy:
        return vars.getValue("testResource");
        }
robinshen ADMIN ·

Yes, that is true. The resource is consumed only if the resource exists.

eranbb ·

Great! works perfectly.
Thanks!