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"]
diff --git a/jenkins/files/groovy/node.template b/jenkins/files/groovy/node.template
index 827e928..d2dc5c6 100644
--- a/jenkins/files/groovy/node.template
+++ b/jenkins/files/groovy/node.template
@@ -32,7 +32,7 @@
                it.remoteFS == "${remote_home}" &&
                it.labelString == "${label}" &&
                it.mode == Node.Mode.${node_mode} &&
-               it.launcher.jvmOptions == "${jvmopts}" &&
+               it.launcher.vmargs == ("${jvmopts}" ?: null) &&
                it.launcher.getClass().getName().equals(launcherName) &&
                it.retentionStrategy.getClass().getName().equals(retStrategyName)
              }