Jenkins SSH从站插件-Groovy配置不起作用

时间:2018-10-04 11:01:52

标签: jenkins groovy ssh

我想将aws ec2实例作为jenkins奴隶。 SSH密钥,用于在已存在的机器之间进行授权。 如果我通过Jenkins Nodes手动设置所有内容,则可以正常工作,当我尝试使用groovy自动设置所有内容时,它将导致脱机。

主要原因 我想在第二个AWS实例上执行jenkins作业,并且应该自动完成与新节点的连接设置。

问题:我该如何用Groovy正确配置ssh从站? 还是有其他可以使其正常工作的插件?

Groovy源代码:

gen-class

环境: 詹金斯版本:2.141 SSH Slave插件版本:1.28.1

Jenkins系统日志错误

// Define a "Launch method": "Launch slave agents via SSH"
SSHLauncher sshLauncher = new hudson.plugins.sshslaves.SSHLauncher(
"slave.target.com", // Host
22, // Port
"sdfsdfsdf-32423-sfd-wer", // Credentials Id
(String)"", // JVM Options
(String)"/usr/bin/java", // JavaPath
(String)"", // Prefix Start Slave Command
(String)"", // Suffix Start Slave Command
(Integer)210, // Connection Timeout in Seconds
(Integer)10, // Maximum Number of Retries
(Integer)15, // The number of seconds to wait between retries
new hudson.plugins.sshslaves.verifiers.NonVerifyingKeyVerificationStrategy() // Host Key Verification Strategy Off because of EC2 Redeploy
)

sshLauncher.setTcpNoDelay(true)

// Define a "Permanent Agent"
hudson.slaves.DumbSlave agent = new hudson.slaves.DumbSlave(
"jenkins-slave", // agent node name
"Jenkins Second Slave", // agent node description
"/home/jenkins", // home directory
"1", // Max Runner
Node.Mode.EXCLUSIVE, // agent mode
"jenkins-slave", // agent label
sshLauncher,
new RetentionStrategy.Always(),
new LinkedList())

List<Entry> env = new ArrayList<Entry>();
env.add(new Entry("node","jenkins-slave"))
env.add(new Entry("JAVA_HOME","/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.amzn2.x86_64/jre"))
EnvironmentVariablesNodeProperty envPro = new EnvironmentVariablesNodeProperty(env);

agent.getNodeProperties().add(envPro)

// Create a "Permanent Agent"
Jenkins.instance.addNode(agent)

Google搜索结果 SSH+Slaves+plugin Doku Good Implementation Examples

0 个答案:

没有答案