From a pipeline perspective I have this workaround
First download in you Jenkins server instance
stage("Download") {
steps {
fileOperations([fileDownloadOperation(password: "", targetFileName: "${params.APP_KEY}.zip", targetLocation: "${params.HOME_PATH}", url: "${params.ARTIFACT_URL}", userName: "")])
}
}
and then copy with a scp instrucction
stage("Download last version") {
sshagent(['xxxx-xxxx-xxxx-xxxx-xxxx']) {
sh "scp ${params.APP_KEY_PATH}/${params.APP_KEY}.ZIP ${params.REMOTE_SERVER_USER}@${params.REMOTE_SERVER_URL}:${params.REMOTE_APP_KEY_PATH}"
}
}
For brevity I am avoiding to put another steps that I change a little bit what I do
But the idea is to do the following steps
- Download the artifact (locally)
- Unzip (locally)
- Create a file with the script I want to execute in the remote server (locally)
- Copy the script to the remote server
- Copy the unziped artifact to the remote server
- Execute the script