有个场景就是:war包的生成与部署分别为两个job,而且所有的war包统一在某个服务器上;
这样就涉及到了war包的拷贝,今天就来分享下拷贝的shell脚本:
下面的几个字段及其相关路径名字换成实际的就行
username:用户名
pwd:密码
ip:ip地址
war-job-name :war包的job
xx.war:war包的名字
expect可以通过 yum来安装
#!/usr/bin/expect
spawn sudo scp -r username@ip:/data/workspace/war-job-name/target/xx.war /data/jenkins
expect {
"(yes/no)?" {
send "yes\n"
expect "*assword:" {set timeout -1;send "pwd\n"}
}
"*assword:" {
set timeout -1;
send "pwd\n"
}
}
expect eof