Creating SSH slaves via java API

64 views
Skip to first unread message

James Hardwick

unread,
Jul 6, 2016, 6:02:59 PM7/6/16
to Jenkins Users
Hi everyone,

I was hoping somebody here might be able to point me in the right direction with regards to launching new SSH slaves via the java API. The javadocs just aren't very clear in this regard and I'm having a heck of a time figuring this out. Not having any luck finding prior examples of this either. 

I'm not interested in using the CLI or REST API. This is being done via a Pipeline groovy script. 

Cheers,
James

James Hardwick

unread,
Jul 6, 2016, 7:02:13 PM7/6/16
to Jenkins Users
Never mind....figured it out (keep in mind this requires the SSH Slaves plugin): 

import hudson.slaves.DumbSlave
import hudson.plugins.sshslaves.SSHLauncher

def jenkins = jenkins.model.Jenkins.instance

def launcher = new SSHLauncher(...)
def slave = new DumbSlave("test slave", "/home/jenkins", launcher)
jenkins.getNodesObject().addNode(slave)
Reply all
Reply to author
Forward
0 new messages