Jenkins docker 自动化部署python3后端 centos8.5 运维系列四

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

 

上一篇:工厂自动化升级改造参考(01)--设备通信协议详解及选型


下一篇:基于ESP32和ESP8266的物联网开发过程(二)