[root@home-ct75211 ~]# vim /etc/nginx/conf.d/my_ok.conf
server { listen 80; server_name www.my-ok.cc; location / { root /usr/share/nginx/html/ok-admin; index index.html index.htm; } }
[root@home-ct75211 ~]# mkdir /data/scripts [root@home-ct75211 ~]# cd /data/scripts/ [root@home-ct75211 ~]# vim /data/scripts/deploy.sh
1 #! /bin/bash 2 job_name=$1 3 app_name=app-$(date +%F)-$(($RANDOM+10000)) 4 echo $app_name 5 cd /var/lib/jenkins/workspace/${job_name} && tar czf /opt/${app_name}.tar.gz ./* 6 cd /var/webroot && mkdir ${app_name} 7 cp /opt/${app_name}.tar.gz /var/webroot/${app_name} 8 cd /var/webroot/${app_name} && tar xf ${app_name}.tar.gz && rm -f ${app_name}.tar.gz 9 cd /usr/share/nginx/html && rm -rf ok-admin && ln -s /var/webroot/${app_name} /usr/share/nginx/html/ok-admin
[root@home-ct75211 scripts]# mkdir /var/webroot
本地测试下
[root@home-ct75211 scripts]# ./deploy.sh my-freestyle-job app-2018-12-15-20566 [root@home-ct75211 scripts]# ll /usr/share/nginx/html/ total 8 -rw-r--r--. 1 root root 537 Dec 4 10:03 50x.html -rw-r--r--. 1 root root 612 Dec 4 10:03 index.html drwxr-xr-x. 3 root root 58 Dec 14 21:37 my_django lrwxrwxrwx 1 root root 33 Dec 15 09:56 ok-admin -> /var/webroot/app-2018-12-15-20566
admin@DESKTOP-BC8FMN2 MINGW64 /e/python/ok-admin (master) $ git fetch $ vim index.html admin@DESKTOP-BC8FMN2 MINGW64 /e/python/ok-admin (master) $ git add . $ git commit -m "modified index.html " [master 03743e9] modified index.html 1 file changed, 2 insertions(+), 2 deletions(-) admin@DESKTOP-BC8FMN2 MINGW64 /e/python/ok-admin (master) $ git push -u origin master Counting objects: 3, done. Delta compression using up to 6 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 321 bytes | 321.00 KiB/s, done. Total 3 (delta 2), reused 0 (delta 0) To 192.168.23.211:py3web/ok-admin.git b731093..03743e9 master -> master Branch ‘master‘ set up to track remote branch ‘master‘ from ‘origin‘.
CentOS7下的Django2集成部署四:Jenkins的freestyle-job