Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-52532

Throws exception when used remote with gateway option

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: ssh-steps-plugin
    • Labels:
      None
    • Environment:
      Jenkins-2.129
      ssh-steps-1.0.0
    • Similar Issues:

      Description

      Code at this line is trying to cast map to Remote object, which requires a change.

      • Change gateway to build similar to how remote build.

      Pipeline:

      def gateway = [:]
      gateway.name = "gateway"
      gateway.host = "gateway.example.net"
      gateway.user = 'user1'
      gateway.password = 'password'
      gateway.allowAnyHosts = true
      
      def remote = [:]
      remote.name = "node-1"
      remote.host = "node1.example.net"
      remote.user = 'user1'
      remote.password = 'password'
      remote.allowAnyHosts = true
      remote.gateway = gateway
      
      node {
        stage("SSH Steps Rocks!") {
          sshCommand remote: remote, command: 'for i in {1..5}; do echo -n \"Loop \$i \"; date ; sleep 1; done'
        }
      }
      

      Exception:

      Also:   hudson.remoting.Channel$CallSiteStackTrace: Remote call to agent-1123
      		at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1741)
      		at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:357)
      		at hudson.remoting.Channel.call(Channel.java:955)
      		at org.jenkinsci.plugins.sshsteps.steps.CommandStep$Execution.run(CommandStep.java:71)
      		at org.jenkinsci.plugins.sshsteps.util.SSHStepExecution$1$1.call(SSHStepExecution.java:77)
      		at hudson.security.ACL.impersonate(ACL.java:290)
      		at org.jenkinsci.plugins.sshsteps.util.SSHStepExecution$1.run(SSHStepExecution.java:72)
      		at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      hudson.remoting.ProxyException: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '{name=gateway, host=chatops.northamerica.cerner.net, allowAnyHosts=true, user=syncmgmt, identity=/home/aeon/jenkins/workspace/NR031563_Custom/gatewayRemote@tmp/secretFiles/8eb0da2e-35ef-47e2-8861-c531e22a5b8f/ssh-key-identity}' with class 'java.util.LinkedHashMap' to class 'org.hidetake.groovy.ssh.core.Remote' due to: groovy.lang.ReadOnlyPropertyException: Cannot set readonly property: allowAnyHosts for class: org.hidetake.groovy.ssh.core.Remote
      	at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransformation.java:403)
      	at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTransformation.java:319)
      	at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:232)
      	at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2715)
      	at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3770)
      	at org.hidetake.groovy.ssh.core.settings.CompositeSettings$With.setProperty(CompositeSettings.groovy)
      	at org.codehaus.groovy.runtime.InvokerHelper.setProperty(InvokerHelper.java:197)
      	at groovy.lang.Closure.setPropertyTryThese(Closure.java:384)
      	at groovy.lang.Closure.setPropertyOwnerFirst(Closure.java:373)
      	at groovy.lang.Closure.setProperty(Closure.java:362)
      	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setGroovyObjectProperty(ScriptBytecodeAdapter.java:532)
      	at org.jenkinsci.plugins.sshsteps.SSHService$_closure1.doCall(SSHService.groovy:106)
      	at org.jenkinsci.plugins.sshsteps.SSHService$_closure1.doCall(SSHService.groovy)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:483)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
      	at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1252)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1215)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810)
      	at org.jenkinsci.plugins.sshsteps.SSHService.invokeMethod(SSHService.groovy)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelegationObjects(ClosureMetaClass.java:446)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:371)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810)
      	at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelegationObjects(ClosureMetaClass.java:446)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:371)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:158)
      	at org.jenkinsci.plugins.sshsteps.SSHService$_executeCommand_closure4$_closure14.doCall(SSHService.groovy:172)
      	at org.jenkinsci.plugins.sshsteps.SSHService$_executeCommand_closure4$_closure14.doCall(SSHService.groovy)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:483)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:57)
      	at org.hidetake.groovy.ssh.util.Utility.callWithDelegate(Utility.groovy:17)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:483)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      	at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.invoke(StaticMetaMethodSite.java:46)
      	at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.callStatic(StaticMetaMethodSite.java:102)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:214)
      	at org.hidetake.groovy.ssh.core.RunHandler.settings(RunHandler.groovy:32)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:483)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:384)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
      	at org.jenkinsci.plugins.sshsteps.SSHService$_executeCommand_closure4.doCall(SSHService.groovy:170)
      	at org.jenkinsci.plugins.sshsteps.SSHService$_executeCommand_closure4.doCall(SSHService.groovy)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:483)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:57)
      	at org.hidetake.groovy.ssh.util.Utility.callWithDelegate(Utility.groovy:17)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:483)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      	at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.invoke(StaticMetaMethodSite.java:46)
      	at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.callStatic(StaticMetaMethodSite.java:102)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:214)
      	at org.hidetake.groovy.ssh.core.Service.evaluateSessions(Service.groovy:104)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:483)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
      	at org.hidetake.groovy.ssh.core.Service.run(Service.groovy:78)
      	at org.hidetake.groovy.ssh.core.Service$run$0.call(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
      	at org.jenkinsci.plugins.sshsteps.SSHService.executeCommand(SSHService.groovy:169)
      	at org.jenkinsci.plugins.sshsteps.steps.CommandStep$Execution$CommandCallable.execute(CommandStep.java:83)
      	at org.jenkinsci.plugins.sshsteps.util.SSHMasterToSlaveCallable.call(SSHMasterToSlaveCallable.java:32)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:212)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:54)
      	at hudson.remoting.Request$2.run(Request.java:369)
      	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      Finished: FAILURE
      

        Attachments

          Activity

          Show
          nrayapati Naresh Rayapati added a comment - PR:  https://github.com/jenkinsci/ssh-steps-plugin/pull/4
          Hide
          nrayapati Naresh Rayapati added a comment -

          Logs after the fix (changed the node names for privacy):

          Host key checking is off. It may be vulnerable to man-in-the-middle attacks.
          [jsch] Permanently added 'gateway.example.net' (RSA) to the list of known hosts.
          Connected to gateway[gateway.example.net:22] (SSH-2.0-OpenSSH_7.4)
          Enabled local port forwarding from localhost:40419 to node-1[node1.example.net:22]
          Host key checking is off. It may be vulnerable to man-in-the-middle attacks.
          [jsch] Permanently added '127.0.0.1' (RSA) to the list of known hosts.
          Connected to node-1[node1.example.net:22] (SSH-2.0-OpenSSH_7.4)
          Started command node-1#1: for i in {1..5}; do echo -n "Loop $i "; date ; sleep 1; done
          node-1|Loop 1 Thu Jul 12 20:03:32 CDT 2018
          node-1|Loop 2 Thu Jul 12 20:03:33 CDT 2018
          node-1|Loop 3 Thu Jul 12 20:03:34 CDT 2018
          node-1|Loop 4 Thu Jul 12 20:03:35 CDT 2018
          node-1|Loop 5 Thu Jul 12 20:03:36 CDT 2018
          Success command node-1#1: for i in {1..5}; do echo -n "Loop $i "; date ; sleep 1; done
          Disconnected from gateway[gateway.example.net:22]
          Disconnected from node-1[node1.example.net:22]
          
          Show
          nrayapati Naresh Rayapati added a comment - Logs after the fix (changed the node names for privacy): Host key checking is off. It may be vulnerable to man-in-the-middle attacks. [jsch] Permanently added 'gateway.example.net' (RSA) to the list of known hosts. Connected to gateway[gateway.example.net:22] (SSH-2.0-OpenSSH_7.4) Enabled local port forwarding from localhost:40419 to node-1[node1.example.net:22] Host key checking is off. It may be vulnerable to man-in-the-middle attacks. [jsch] Permanently added '127.0.0.1' (RSA) to the list of known hosts. Connected to node-1[node1.example.net:22] (SSH-2.0-OpenSSH_7.4) Started command node-1#1: for i in {1..5}; do echo -n "Loop $i " ; date ; sleep 1; done node-1|Loop 1 Thu Jul 12 20:03:32 CDT 2018 node-1|Loop 2 Thu Jul 12 20:03:33 CDT 2018 node-1|Loop 3 Thu Jul 12 20:03:34 CDT 2018 node-1|Loop 4 Thu Jul 12 20:03:35 CDT 2018 node-1|Loop 5 Thu Jul 12 20:03:36 CDT 2018 Success command node-1#1: for i in {1..5}; do echo -n "Loop $i " ; date ; sleep 1; done Disconnected from gateway[gateway.example.net:22] Disconnected from node-1[node1.example.net:22]
          Hide
          nrayapati Naresh Rayapati added a comment -

          Merged Pull request, will release it soon. 

          Show
          nrayapati Naresh Rayapati added a comment - Merged Pull request, will release it soon. 
          Hide
          nrayapati Naresh Rayapati added a comment -

          Released this with 1.1.0. Closing.. Thank you.

          Show
          nrayapati Naresh Rayapati added a comment - Released this with 1.1.0 . Closing.. Thank you.

            People

            Assignee:
            nrayapati Naresh Rayapati
            Reporter:
            nrayapati Naresh Rayapati
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: