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

Unable to set number of executors on slave through Groovy system script

      I would like to set the number of executors on a slave node in a build step. I tried doing that with a Groovy system script, but it seems to me this is not possible, since the setNumExecutors(int) method is only implemented by jenkins.model.Jenkins, which will however only affect the master node. The method is not accessible through the 'Node', 'Slave' or 'Computer' classes, which would allow me to do that on a slave. For example, like this

      Hudson.instance.getComputer("SlaveName").setNumExecutors(1)

          [JENKINS-23534] Unable to set number of executors on slave through Groovy system script

          vjuranek added a comment -

          Changed to feature request and more into core component. Groovy plugin just provides convenient access to Jenkins classes, if any public API is missing, it should be added into Jenkins core, not implemented as some workaround in Groovy plugin.

          vjuranek added a comment - Changed to feature request and more into core component. Groovy plugin just provides convenient access to Jenkins classes, if any public API is missing, it should be added into Jenkins core, not implemented as some workaround in Groovy plugin.

          Daniel Beck added a comment -

          Might be sufficient to make Computer.setNumExecutors(int) public, but I have no idea what the side effects of that would be.

          Daniel Beck added a comment - Might be sufficient to make Computer.setNumExecutors(int) public, but I have no idea what the side effects of that would be.

          Jesse Glick added a comment -

          It is intentionally private since Jenkins does not offer a way to change the number of executors of a SlaveComputer or Slave once created. Instead, you change the configuration, meaning replacing the existing Slave.

          Jesse Glick added a comment - It is intentionally private since Jenkins does not offer a way to change the number of executors of a SlaveComputer or Slave once created. Instead, you change the configuration, meaning replacing the existing Slave .

          Mark Sinclair added a comment -

          I'm also trying to change the number of executors on a slave via a groovy script. I'm able to update some parameters of the slave config, such as label, but can not access the setNumExecutors method.

          I'm trying to understand the above comment - How do I accomplish this by "change the configuration, replacing the existing slave" via a groovy script?

          Mark Sinclair added a comment - I'm also trying to change the number of executors on a slave via a groovy script. I'm able to update some parameters of the slave config, such as label, but can not access the setNumExecutors method. I'm trying to understand the above comment - How do I accomplish this by "change the configuration, replacing the existing slave" via a groovy script?

          Daniel Beck added a comment -

          msinclair Do what core Jenkins does. (Requires a look into the sources.)

          System Groovy is about as unsupported as it gets, so from a Jenkins project perspective, you're on your own.

          Daniel Beck added a comment - msinclair Do what core Jenkins does. (Requires a look into the sources.) System Groovy is about as unsupported as it gets, so from a Jenkins project perspective, you're on your own.

            vjuranek vjuranek
            dengste David Engster
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: