int128 / gradle-ssh-plugin

Gradle SSH Plugin
https://gradle-ssh-plugin.github.io
Apache License 2.0
320 stars 59 forks source link

put method tips Failed SFTP MKDIR #285

Open muyun12 opened 7 years ago

muyun12 commented 7 years ago

Hi

plugin: 2.6.0

my operations ssh.run { session(remotes.syf) { put from: "${project.rootDir}/builder/${project.name}", into: '/home/syf/sshupload' } }

console tips:

Failed SFTP MKDIR: syf:/home/syf/sshupload/tax_settle Failed SFTP MKDIR: syf:/home/syf/sshupload/tax_settle/jsp Failed SFTP MKDIR: syf:/home/syf/sshupload/tax_settle/jsp/grp Failed SFTP MKDIR: syf:/home/syf/sshupload/tax_settle/jsp/grp/grwb Failed SFTP MKDIR: syf:/home/syf/sshupload/tax_settle/jsp/grp/gspi Failed SFTP MKDIR: syf:/home/syf/sshupload/tax_settle/jsp/grp/grwb Failed SFTP MKDIR: syf:/home/syf/sshupload/tax_settle/jsp/grp/gspi Failed SFTP MKDIR: syf:/home/syf/sshupload/tax_settle/jsp/lcm Failed SFTP MKDIR: syf:/home/syf/sshupload/tax_settle/jsp/lcm/cpws Failed SFTP MKDIR: syf:/home/syf/sshupload/tax_settle/jsp/lcm/tdtf Failed SFTP MKDIR: syf:/home/syf/sshupload/tax_settle/jsp/lcm/tspi Failed SFTP MKDIR: syf:/home/syf/sshupload/tax_settle/jsp/lcm/cpws Failed SFTP MKDIR: syf:/home/syf/sshupload/tax_settle/jsp/lcm/tdtf

but files had uploaded. why?

altavir commented 7 years ago

The same for me:

        ssh.run {
            session(remotes.mipt) {
                for (f in file('target').listFiles()) {
                    put from: f, into: '/var/www/html', fileTransfer: 'scp'
                }
            }
        }

Resulting in:

Host key checking is off. It may be vulnerable to man-in-the-middle attacks.
Failed SFTP MKDIR: mipt:/var/www/html/files
Failed SFTP MKDIR: mipt:/var/www/html/fonts
...

Files are still being copied.

By the way is there easier way directory content but not directory itself? The documentation is a little vague about it.

beerd7017 commented 7 years ago

I also am running into Failed SFTP MKDIR:

@altavir to get just the content of the directory you could do something like this:

FileTree myFileTree = fileTree(dir: 'myLocalDirectory')

ssh.run {
            session(remotes.mipt) {
                  put from: myFileTree.getFiles(), into: '/var/www/html'
            }
lukashevich-t commented 5 years ago
def remoteDir = "/home/uploader/123"
ssh.run {
    [remotes.appsrv1].each {
        session(it) {
            execute("mkdir -p ${remoteDir}")
            put from: 'build', into: remoteDir
        }
    }
}

result:

# gradlew deploy

> Task :online_listener:deploy FAILED
Failed SFTP MKDIR: appsrv1:build//home/uploader/123/classes

FAILURE: Build failed with an exception.

* Where:
Build file 'D:\work\idea\erip\online_listener\build.gradle' line: 69

* What went wrong:
Execution failed for task ':online_listener:deploy'.
> org.hidetake.groovy.ssh.operation.SftpException: Failed SFTP MKDIR: appsrv1:build//home/uploader/123/classes: (SSH_FX_NO_SUCH_FILE: A reference was made to a file which does not exist): No such file

directory /home/uploader/123/build/ gets created.

but appsrv1:build//home/uploader/123/classes must be appsrv1:/home/uploader/123/build/classes

I use Gradle 5.0 on Windows.

Is this plugin supported? Bug was issued more than 2 years ago.

pafalium-2nd commented 2 months ago

@lukashevich-t That error is probably a bug that was fixed in version 2.10.0 of the plugin. The plugin wasn't handling sub-directories correctly. A workaround for someone using versions prior to 2.10.0 is to use fileTransfer = scp.

In our case, the workaround was to use fileTransfer = scp (we were using version 2.9.0 of the plugin and Gradle 8.4).