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

sshPut replicates local directory structure even when transferring single files

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Major Major
    • ssh-steps-plugin
    • None
    • Jenkins 2.501
      SSH Pipeline Steps 2.0.79.v1d1b_5f76dda_8

      Push "demo.txt" under the local "test-dir" to the remote "/tmp/ssh-test/". The "test-dir" directory will be created automatically. It is not possible to put "demo.txt" under the "/tmp/ssh-test/" directory.

      Even if I switch the working directory to "test-dir", it still doesn't work.
      Example

      pipeline {
       agent any
       stages {
        stage('Test') {
         steps {
          sh 'mkdir -p test-dir && echo "test" > test-dir/demo.txt' // Create local directory structure
          
           sshPut remote: [host: 'remote-ip', user: 'user', password: 'pass'],
             from: '.', into: '/tmp/ssh-test' // Transfer current directory
          }
          sshCommand remote: [host: 'remote-ip', user: 'user', password: 'pass'],
             command: 'ls -l /tmp/ssh-test' // Verify remote path
         }
        }
       }
      }

       Observed Behavior

      Remote path contains local directory structure:

      /tmp/ssh-test/test-dir/demo.txt

      Expected Behavior

      Files should be directly copied to specified into path:

      /tmp/ssh-test/demo.txt

            huangsijun17 huangsijun17
            huangsijun17 huangsijun17
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: