How to copy file to a remote machine using gradle?

I need to copy file from one machine to another machine using Gradle. For that I need to remotely access the other machine. Could anyone please help in this?

You can try the gradle ssh plug-in
https://gradle-ssh-plugin.github.io/

@Francois_Guillot : I have tried the gradle ssh plug-in but it is giving me the following error-

java.net.ConnectException: Connection refused: connect

Could you please let me know how to proceed from here. Following is the gradle script that I wrote.

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.hidetake:gradle-ssh-plugin:1.1.4’
classpath ‘org.codehaus.groovy:groovy-backports-compat23:2.3.6’
}
}

apply plugin: ‘org.hidetake.ssh’

remotes {
web01 {
//role 'handHeldMachine’
host = 'remoteHost’
user = 'esg-cibuilder’
password = ‘itSaSecret01’
}
}

task deploymentToHHMachine() << {
File configFile = new File( ‘test-agent.conf’ )
ssh.run {
session(remotes.web01) {
put from: qnxConfigFile, into: ‘C:\Thrift’
}
}
}

The vfs plugin is another alternative.