I want to do SCP
from Windows Jenkins node to Linux server. In this set up, Windows machine is a Jenkins slave and the target server where i want to copy is Lin
Give this a shot:
pipeline {
agent any
stages {
stage('SCP JAR file') {
steps {
bat '"c:\\Program Files\\git\\usr\\bin\\scp.exe" -i "c:\\Users\\tom\\.ssh\\azure\\id_rsa" C:\\Users\\tom\\.jenkins\\workspace\\scp-to-linux\\abc.jar tom@xy.xyz.xy.xz:abc.jar'
bat '"c:\\Program Files\\git\\usr\\bin\\ssh.exe" -i "c:\\Users\\tom\\.ssh\\azure\\id_rsa" tom@xy.xyz.xy.xz ls -ltr'
}
}
}
}
Note: While doing scp
, if you do not specify the destination file name, it will create file on remote server with the complete source path name. For example, in my case, it would have created file with the name C:\Users\tom\.jenkins\workspace\scp-to-linux\abc.jar
on remote server had i not specified this syntax: tom@xy.xyz.xy.xz:abc.jar