import jenkins.model.*
import hudson.security.*
import hudson.slaves.*
import hudson.plugins.sshslaves.*
import hudson.model.*
SLAVE_IP_ADDR="172.17.1.55"
SLAVE_LOGIN="root"
SLAVE_PWD="root"
SLAVE_NODE_LABEL="My_Slave_Node_Autogenerated-Label"
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)
The above url might help you to understand what that plugin does
Cheers
public DumbSlave(String name, String nodeDescription, String remoteFS, String numExecutors, Node.Mode mode, String labelString, ComputerLauncher launcher, RetentionStrategy retentionStrategy, List<? extends NodeProperty<?>> nodeProperties) throws IOException, Descriptor.FormException
import jenkins.model.*
import hudson.model.*
import hudson.slaves.*
import hudson.plugins.sshslaves.*
import java.util.ArrayList;
import hudson.slaves.EnvironmentVariablesNodeProperty.Entry;
import com.synopsys.arc.jenkinsci.plugins.jobrestrictions.nodes.JobRestrictionProperty;
import com.synopsys.arc.jenkinsci.plugins.jobrestrictions.Messages;
import com.synopsys.arc.jenkinsci.plugins.jobrestrictions.restrictions.JobRestriction;
import com.synopsys.arc.jenkinsci.plugins.jobrestrictions.restrictions.JobRestrictionBlockageCause;
import hudson.Extension;
import hudson.model.Node;
import hudson.model.Queue;
import hudson.model.queue.CauseOfBlockage;
import hudson.slaves.NodeProperty;
import hudson.slaves.NodePropertyDescriptor;
import org.kohsuke.stapler.DataBoundConstructor;
List<Entry> env = new ArrayList<Entry>();
env.add(new Entry("key1","value1"))
env.add(new Entry("key2","value2"))
EnvironmentVariablesNodeProperty envPro = new EnvironmentVariablesNodeProperty(env);
Slave slave = new DumbSlave(
"agent-node","Agent node description",
"/home/jenkins",
"1",
Node.Mode.NORMAL,
"agent-node-label",
new SSHLauncher("agenNode",22,"user","password","","","","",""),
new RetentionStrategy.Always(),
new LinkedList())
slave.getNodeProperties().add(envPro)
Jenkins.instance.addNode(slave)
import jenkins.model.*
import hudson.model.*
import hudson.slaves.*
import hudson.plugins.sshslaves.*
import com.synopsys.arc.jenkinsci.plugins.jobrestrictions.nodes.JobRestrictionProperty;
import com.synopsys.arc.jenkinsci.plugins.jobrestrictions.restrictions.job.StartedByUserRestriction;
import com.synopsys.arc.jenkinsci.plugins.jobrestrictions.util.UserSelector;
import java.util.List;
List<UserSelector> usersList;
UserSelector u1 = new UserSelector ("user1");
List userlist = new LinkedList();
userlist.add(u1);
StartedByUserRestriction startuserrect = new StartedByUserRestriction(userlist, false, false,false );
JobRestrictionProperty jobrestrict = new JobRestrictionProperty(startuserrect);
List restrictlist = new LinkedList();
restrictlist.add(jobrestrict);
Slave slave = new DumbSlave(
"agent-node",
"Agent node description",
"/home/jenkins",
"1",
Node.Mode.NORMAL,
"agent-node-label",
new SSHLauncher("172.17.1.55",22,"root","root","","","","",""),
new RetentionStrategy.Always(),
restrictlist)
Jenkins.instance.addNode(slave)