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

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

    Details

    • Similar Issues:

      Description

      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)

        Attachments

          Activity

          Hide
          vjuranek 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.

          Show
          vjuranek 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.
          Hide
          danielbeck 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.

          Show
          danielbeck 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.
          Hide
          jglick 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.

          Show
          jglick 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 .
          Hide
          msinclair 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?

          Show
          msinclair 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?
          Hide
          danielbeck Daniel Beck added a comment -

          Mark Sinclair 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.

          Show
          danielbeck Daniel Beck added a comment - Mark Sinclair 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.

            People

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

              Dates

              • Created:
                Updated:
                Resolved: