1安装expect
yum install expect
2 jenkins 新建任务
#cat qysup.sh
#!/usr/bin/expect -f
set port 22
set user root
set host ip
set password 密码
set timeout 60
spawn ssh $user@$host
expect "password:"
send "$password\r"
expect "]#"
###
send "docker exec -it 容器名字 /bin/bash \r"
send "cd /opt/;git pull \r"
send "sleep 6 \r"
send "sh /data/stop.sh \r"
send "sleep 2 \r"
send "cd /opt/zld/;python manage.py makemigrations \r"
send "sleep 9 \r"
send "cd /opt/;python manage.py migrate \r"
send "sleep 3 \r"
send "sh /data/start.sh \r"
send "sleep 2 \r"
send "exit \r"
expect "jsZ ~]#"
expect eof