Search code examples
gradlesshscp

How do you make the gradle SSH plugin use SCP instead of SFTP?


I'm using the gradle SSH plugin to copy a docker file to a target host. It defaults to SFTP but I'd prefer to use SCP. The documentation does not provide a clear example of how to do this and it's late and I'm tired and...

So anyway, here's what is working for me with SFTP:

ssh.run {
  session(remotes.my_host) {
    put from:"${dockerImageArchive}", into:"/tmp"
  }
}

Here's what the docs say I need to do to switch to SCP: gradle ssh documentation snippet

I'm pretty new to gradle and I don't understand how I'm supposed to supply this parameter. Can someone spell it out for me? :)

FWIW I've tried this

ssh.run {
  session(remotes.my_host) {
    put from:"${dockerImageArchive}", into:"/tmp", fileTransfer:"scp"
  }
}

Solution

  • Hmmm, turns out this was waaay easier than I expected. I needed to add this to my build.gradle (could have also been added somewhere else in the inheritance hierarchy)

    ssh.settings {
      fileTransfer = 'scp'
    }