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

sshPut is not working from inside of a containerized build environment

XMLWordPrintable

      The Jenkinsfile is as follows:

      def remote = [name: 'whatever', host: '192.168.111.2', user: 'vagrant', password: 'vagrant', allowAnyHosts: true]
      
      pipeline {
          agent { dockerfile true }
          stages {
              stage('Initialize') {
                  steps {
                      checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'mybitbucketcredential', url: '<<REDACTED>>']]])
                      
                      sh 'pwd'
                      sh 'ls -l install.sh'
                      sshPut remote: remote, from: 'install.sh', into: 'deploymentpackages/.'
                  }
              }
          }
      }
      
      

      Relevant parts of the error log:

      + pwd
      /var/jenkins_home/workspace/MyExperiments/TrafoPoC
      [Pipeline] sh
      + ls -l install.sh
      -rw-r--r-- 1 1000 1000 161 Sep 29 10:23 install.sh
      [Pipeline] sshPut
      Sending a file/directory to whatever[192.168.111.2]: from: /var/jenkins_home/workspace/MyExperiments/TrafoPoC/install.sh into: deploymentpackages/.
      Failed SFTP PUT: /var/jenkins_home/workspace/MyExperiments/TrafoPoC/install.sh -> whatever:deploymentpackages/.
      
      2: No such file
      	at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2873)
      	at com.jcraft.jsch.ChannelSftp._put(ChannelSftp.java:594)
      	at com.jcraft.jsch.ChannelSftp.put(ChannelSftp.java:475)
      	at com.jcraft.jsch.ChannelSftp$put.call(Unknown Source)
      	at org.hidetake.groovy.ssh.operation.SftpOperations$_putFile_closure3.doCall(SftpOperations.groovy:67)
      	at org.hidetake.groovy.ssh.operation.SftpOperations$_putFile_closure3.doCall(SftpOperations.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:498)
      	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.AbstractCallSite.call(AbstractCallSite.java:117)
      	at org.hidetake.groovy.ssh.operation.SftpOperations.tryCatchSftpException(SftpOperations.groovy:170)
      Caused: org.hidetake.groovy.ssh.operation.SftpException: Failed SFTP PUT: /var/jenkins_home/workspace/MyExperiments/TrafoPoC/install.sh -> whatever:deploymentpackages/.: (SSH_FX_NO_SUCH_FILE: A reference was made to a file which does not exist): No such file
      

       

      Contents of Dockerfile:

      FROM ubuntu:20.04
      
      RUN apt-get update && apt-get install -y zip
      

       

      sshPut is unable to upload a file to a remote machine, although the file clearly exists.

            nrayapati Naresh Rayapati
            restbndr Anvar Sosnitski
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: