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

To create a JobRestriction's NodeProperty and adding it to the node via a groovy code

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Fixed
    • Icon: Blocker Blocker
    • None
    • Jenkins version 2.10 , Job Restrictions Plugin version 0.5

      Hi All ,

      I have the below groovy code which creates a slave node

      import jenkins.model.*

      import hudson.model.*

      import hudson.slaves.*

      import hudson.plugins.sshslaves.*

      println "create a slave node.. \n\r"

      Slave slave_node = new DumbSlave(

      "My_Slave_Node_Autogenerated",

      "This slave node is generated using a jenkins job via groovy script",

      "/home/jenkins",

      "1",

      Node.Mode.NORMAL,

      SLAVE_NODE_LABEL,

      new SSHLauncher(SLAVE_IP_ADDR,22,SLAVE_LOGIN,SLAVE_PWD,"","","","",""),

      new RetentionStrategy.Always(),

      new LinkedList()

      )
      Jenkins.instance.addNode(slave_node)

      Which groovy steps should I adding to above groovy script to create below changes (attached) for slave node configuration as shown in the pic below

      Any pointers how to enable "restrict jobs execution at node " for the above create slave node using groovy script .

      Please assign this ticket to : Oleg Nenashev <o.v.nenashev@gmail.com> as he requested by him.

      Hi Oleg,

      Could you please help in assisting me in giving those groovy steps by which I can create/edit the node properties for any newly created slave node ,via "Restrict jobs execution at node " as shown in the attached document.

      Thanks,
      Amit

      Any help will be appreciated

            oleg_nenashev Oleg Nenashev
            amitkumar_ghatwal Amitkumar Ghatwal
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: