maven 命令
clean package
shell 命令
#!/usr/bin/expect
#环境配置部分
set remote_ip your_host
set port your_port
set username yours
set password yours
set target_dir your_target
set war_name uip.war
set tomcat_name tomcat_name
set jenkins_workspace /Users/yugj/.jenkins/workspace
set job_name remote-deploy
set timeout 30
spawn scp -P $port $jenkins_workspace/$job_name/target/$war_name $username@$remote_ip:$target_dir
expect {
"*yes/no*" {
send "yes\n"
expect "*password:"
send "$password\n"
}
"$username@$remote_ip's password:" {
send "$password\n"
}
}
set timeout 60
expect eof
spawn ssh -p $port $username@$remote_ip
set timeout 30
expect {
"*yes/no" {
send "yes\n"
expect "*password:"
send "$password\n"
}
"*password:" {
send "$password\n"
}
}
expect "Last*"
send "
cd $target_dir
ls | grep -v $war_name | xargs rm -rf
unzip $war_name
rm -rf $war_name
ps aux | grep java | awk '/$tomcat_name/{print \$2}'|xargs kill -9
/usr/local/$tomcat_name/bin/startup.sh
echo 'starting tomcat ...'
/home/shell_scripts/tail-F.sh $tomcat_name 30
"
expect eof
set timeout 30
exit 0