1.首先在宿主机安装sshpass
2.把物理机的sshpass复制到容器中
which sshpass
cp $(which sshpass) /usr/local/app/
docker cp sshpass 容器id:/usr/local/bin/sshpass
3.在jenkinsfile中添加
#在stages中添加stage
stage('部署TEST服务'){
steps{
sh "sshpass -p root1234 scp -o StrictHostKeyChecking=no -r /var/jenkins_home/workspace/one-code-all/dist/static/ [email protected]:/opt/app/middles/nginx-1.20.2/html/"
sh "sshpass -p root1234 ssh -o StrictHostKeyChecking=no [email protected] mv /opt/app/middles/nginx-1.20.2/html/afp /opt/app/middles/nginx-1.20.2/html/afp_bak"
sh "sshpass -p root1234 ssh -o StrictHostKeyChecking=no [email protected] mv /opt/app/middles/nginx-1.20.2/html/static /opt/app/middles/nginx-1.20.2/html/afp"
}
}
标签:opt,另一台,app,DevOps,---,nginx,html,sshpass,afp
From: https://www.cnblogs.com/hujunwei/p/17829696.html