I have a Jenkinsfile which implements a pipeline and in one of the stages and under a node, if I say unstash 'myfile', where this 'myfile' will be available on the node? My requirement is I need to access this file and copy to a known remote server (this remote server is not part of Jenkins pool) as part of the Jenkinsfile script.
You can use SSH Pipeline Steps to copy file to a remote server. Here is example how to send file from job workspace to remote host:
remote = [:]
remote.name = "name"
remote.host = "remote_ip"
remote.allowAnyHosts = true
remote.failOnError = true
withCredentials([usernamePassword(credentialsId: 'credentials_name', passwordVariable: 'password', usernameVariable: 'username')]) {
remote.user = username
remote.password = password
}
sshPut remote: remote, from: 'myfile', into: 'folder_on_remote_host'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With