Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-55672

Howto define a fallback label in case all hosts for default label are busy?

XMLWordPrintable

      Unfortunately the pluign documentation is a bit short and should cover more use cases. One of them is the assignment of a default label and, in case all hosts with that label are busy, a fallback label so that the job only has to wait if all hosts with both labels are busy. This would allow to specify a preference for faster hosts and fall back to slower ones if all fast hosts are busy.

      Here's what I've tried so far:

      import jenkins.model.Jenkins
      
      Jenkins.instance.getLabel('FastHost').getNodes().each { agent ->
        def executors = agent.getComputer().numExecutors
        def busy = agent.getComputer().countBusy()
        if (busy < executors) {
          return "FastHost"
        }
      }
      return "SlowHost"
      

      But this always returns "SlowHost", no matter how many executors are free on "FastHost" hosts.

            dhs Dirk Heinrichs
            dhs Dirk Heinrichs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: