jenkins 插件Publish Over SSH (sskey) 同步文件夹
一、安装插件
Publish Over SSH
SSH Pipeline Steps
二、添加sshkey
将ssh免密登录的私钥新建到
二、准备目录
源:images
目标:/root/images2
流水线脚本
pipeline {
agent any
stages {
stage('Dest') {
steps {
script{
def remote = [:]
remote.name = 'tst'
remote.host = '192.168.31.142'
remote.port = 22
remote.allowAnyHosts = true
sh 'tar czvf demo.tar.gz ./images/*'
withCredentials([sshUserPrivateKey(credentialsId: 'linux-142-ssh', keyFileVariable: 'identity', passphraseVariable: '', usernameVariable: 'userName')]) {
remote.user = userName
remote.identityFile = identity
sshPut remote:remote,from:'./demo.tar.gz',into:'/root/images2/'
sshCommand remote:remote,command:"cd /root/images2/ && sudo tar xzvf demo.tar.gz"
}
}
}
}
}
}
原文地址:https://blog.csdn.net/xiaoxionglove/article/details/142887334
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!