Update ssh slave management
PROD-30944
Change-Id: If841f6da0b9b6c7693787d4acd28722f1b19d1f9
diff --git a/_states/jenkins_node.py b/_states/jenkins_node.py
index 29e9c2c..8b3a4b9 100644
--- a/_states/jenkins_node.py
+++ b/_states/jenkins_node.py
@@ -54,13 +54,19 @@
launcher_string = "new hudson.slaves.JNLPLauncher()"
tunnel_string = ""
jvmopts_string = ""
- if "jvmopts" in launcher:
- jvmopts_string = launcher["jvmopts"]
if launcher:
+ if "jvmopts" in launcher:
+ jvmopts_string = launcher["jvmopts"]
if launcher["type"] == "ssh":
- launcher_string = 'new hudson.plugins.sshslaves.SSHLauncher("{}",{},"{}","{}","","{}","","","")'.format(
- launcher["host"], launcher["port"], launcher["username"],
- launcher["password"], jvmopts_string)
+ if "credentials" in launcher:
+ # Constructor based on ssh-slaves plugin of 1.29+ versions
+ launcher_string = 'new hudson.plugins.sshslaves.SSHLauncher("{}",{},"{}","{}","","","",null,null,null,null)'.format(
+ launcher["host"], launcher["port"], launcher["credentials"], jvmopts_string)
+ else:
+ # Deprecated: Constructor based on old ssh-slaves plugin versions (~1.17)
+ launcher_string = 'new hudson.plugins.sshslaves.SSHLauncher("{}",{},"{}","{}","","{}","","","")'.format(
+ launcher["host"], launcher["port"], launcher["username"],
+ launcher["password"], jvmopts_string)
elif launcher["type"] == "jnlp":
if "tunnel" in launcher:
tunnel_string = launcher["tunnel"]