Step1:构建一个自由风格的php-deploy

Step2:Gernal配置,丢弃旧的构建,防止jenkins构建较多以后变臃肿

Step3:源码管理:这里使用git插件,也可使用svn插件

将git路径存在这里还须要权限认证,不然会出现error 。
jenkins服务器上生成SSH-Key
[root@linux-node2 ~]# yum install -y git
[root@linux-node2 ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:00FQjn5P6qAtok4BuE42TyfuNJnblzZ389XwKBhmHjY root@linux-node2
The key's randomart image is:
+---[RSA 2048]----+
| .oo |
|. + |
|o . o |
| o . . . |
|.+.o . S E . . |
|+ =.= B O +.|
| ..B o + o ..o|
| .o = .B + o .. |
| .o+ o+.+ o o. |
+----[SHA256]-----+
[root@linux-node2 ~]# cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+/XyUMNP5Wm63hhcACosVyRtmJxTSnT46HSKZ2PhduTHPIJcfhVTmeCk1zwO0fP8PmwXFf0+G9ki8CupE/+xcOy14TCqxNgvP8o514IjXOFV7SO1lnHKH3t0RfaFEloRZHnrgIcWiZrFvYRT/TFznWO86sfHPzlW6WF9elTqRURNR60bwv9C6iw4PpYjGVIST/SeGl75axtUjJr544jB5pEWtNZ09ktCKpPeFBvgCc9exdzOQuzaCXQrroNU0p6MB6KkoIOmpkN92cDPdg4EgBYDjwcl38FbXOq3N0QL8PT+IZpHBWFVEAZU2alI02H5NNUy9p2K/Br4NY3UvYZiP root@linux-node2


命令行测试添加ssh-key后可否正常拉取
[root@linux-node2 ~]# git clone git@192.168.56.11:java/app1.git
Cloning into 'app1'...
The authenticity of host '192.168.56.11 (192.168.56.11)' can't be established.
ECDSA key fingerprint is SHA256:p2lhKmsPQ6K+dWHHvbJg0GV+Ni9VM7vlViKrYsZLP1s.
ECDSA key fingerprint is MD5:22:14:1c:37:de:47:1c:4a:2f:88:b1:dc:e2:d0:02:17.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.56.11' (ECDSA) to the list of known hosts.
remote: Counting objects: 11, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 11 (delta 0), reused 11 (delta 0)
Receiving objects: 100% (11/11), done.
[root@linux-node2 ~]# ll
total 68048
-rw-------. 1 root root 948 Dec 3 01:26 anaconda-ks.cfg
drwxr-xr-x 3 root root 62 Dec 21 15:53 app1
-rw-r--r-- 1 root root 69675984 Mar 2 2017 jenkins-2.32.3-1.1.noarch.rpm

而后保存,当即构建一次,会拉取master的代码库

点开
能够看到控制台的输出,如图:

/var/lib/jenkins/workspace/php-deploy目录用于存放代码信息
[root@linux-node2 php-deploy]# ll
total 12
-rw-r--r-- 1 root root 28 Dec 21 16:11 index.html
-rw-r--r-- 1 root root 12 Dec 21 16:11 new.html
-rw-r--r-- 1 root root 19 Dec 21 16:11 readme
[root@linux-node2 php-deploy]# pwd
/var/lib/jenkins/workspace/php-deploy
这里咱们拉取的代码须要推送到远程代码目录,须要以下操做:
架设linux-node1为web服务,目录为/data/www/php-deploy
[root@linux-node1 ~]# mkdir /data/www/php-deploy -p
添加node2的免秘钥登录
[root@linux-node1 ~]# vim .ssh/authorized_keys
[root@linux-node1 ~]# chmod 600 .ssh/authorized_keys
[root@linux-node2 ~]# ssh 192.168.56.11
Last login: Mon Dec 4 17:41:56 2017 from 192.168.56.1
[root@linux-node1 ~]#
修改项目设置,配置构建:Execute shell,至关于将代码自动发布到linux-node1的代码目录中。

接下来,咱们从新构建一次,并查看控制台输出:

在node1上查看目录,也会有相应的代码信息
[root@linux-node1 ~]# ll /data/www/php-deploy/
total 12
-rw-r--r-- 1 root root 28 Dec 21 16:11 index.html
-rw-r--r-- 1 root root 12 Dec 21 16:11 new.html
-rw-r--r-- 1 root root 19 Dec 21 16:11 readme
[root@linux-node1 ~]#
#########################################################################
Jenkins的远程管理方式包含:
Shell ssh
SSH Plugin
ansible、saltstack
(1)Shell ssh
在项目构建时,jenkins使用了Execute Shell直接对远程主机操做,同步了代码到主机192.168.56.11上,而且能够增长对远程机器进行操做。例如执行某个脚本:ssh root@192.168.53.11 "/bin/sh /data/scripts/****.sh "
如图:

(2)SSH plugin
除了以上方法以外,还可使用SSH 的插件--SSH plugin
系统管理-->系统配置-->SSH remote hosts,配置好远程主机

在项目中配置,如图:

这样就完成了对远程主机的管理
此外,还可使用自动化工具,如ansible,saltstack,模式一致,只是用的是ansible或者是saltstack的命令行工具的不一样。
当业务量变大时,单台的jenkins进行自动化构建部署,就显得没那么灵活,下面介绍jenkins的集群功能。
jenkins的集群并不是像web服务器,mysql集群,jenkins的集群无需在额外的主机安装jenkins,可是用于java项目来讲,要使用集群功能,额外的主机就必需要安装maven。
(1)在jenkins的web界面:系统管理-->Configure Global Security-->TCP port for JNLP agent配置端口30000

(2)系统管理-->管理节点-->新建节点

(3)分配任务到节点
在项目中配置:
General-->Restrict where this project can be run-->Label Expression:node-01


此时,在对项目进行构建,将会分配到node-01节点上进行构建,如图:

当一个公司的开发分为多个组别,或者是多个项目等等。用于公司内部测试,让开发人员自行构建测试,此时不可能让全部的开发都在公用一个构建,这样变得很混乱,为了解决这一问题,jenkins也提供了角色受权的机制。每一个开发有着对应的帐号和权限,能够自行新建,构建,测试,发布等。角色受权须要安装的插件:Role-based Authorization Strategy
(1)系统配置
系统管理-->Configure Global Security-->访问控制-->受权策略-->Role-Base Strategy

(2)新建用户
系统管理-->管理用户-->新建用户
这里建立一个java用户和php用户,用于区分php和java项目的构建

(3)用户关联本身相关job,没法查看其余的job
创建项目角色,并对该用户进行项目的受权(包括Job的构建,取消,配置,建立,删除等等)
注意此处的添加,一个是Role是随意填写,最好规范点。Pattern是正则匹配,好比此处匹配的是全部包含Java开头的项目和php开头的项目
系统管理-->Manage and Assign Roles --> Manage Roles-->Project roles

配置好项目的权限,使用java用户或php用户登陆是没有新建项目的权限,如需新增这样的权限,须要在Global roles中进行配置,新增一个角色(好比新增一个能够建立新项目的权限角色:new job,可登陆查看的角色read):

而后系统管理-->Manage and Assign Roles -->Assign Roles进行添加对应的权限

使用php登陆查看,能够看到php用户能够看到对应php开头的项目,可是没有新建项目的权限:

-
2、Jenkins的Pipeline(代码流水线管理)
Pipeline(代码流水线管理)
Pipeline名词顾名思义就是流水线的意思,由于公司可能会有不少项目。若是使用jenkins构建完成后,开发构建项目须要一项一项点击,比较麻烦。因此出现pipeline名词。
(1)下载pipeline。这样只须要构建一个项目,就会帮咱们完成全部相关项目
搜索插件pipeline

等待安装完成

(2)新建一个pipeline的项目

配置pipeline项目,使用Pipeline script脚本:
node {
stage 'build php-deploy'
build 'php-deploy'
stage 'build java'
build 'java'
}
为了解决各个项目的依赖关系关系,使用pipeline的脚本进行控制。
第一步构建php项目,第二步构建java项目。Pipeline的脚本语法在Pipeline Syntax中有展现

Pipeline Syntax的使用,如图:

当即构建p1的项目,如图:

代码流水线的功能就介绍到此!
思路图:

jenkins-->系统管理-->管理插件-->下载并安装gitlab plugin
路径:Jenkins-->Credentials-->System-->Global credentials(unrestricted)-->Add Credentials
一、Kind选择Gitlab API token
二、其中API token填写gitlab中有库权限的帐号
三、ID填写用户帐号

gitlab生成Api token,将生成的token填入上面的证书内。


路径:系统管理-->系统设置
一、填写链接名
二、填写gitlab访问URL
三、选择gitlab认证
三、测试链接

-
4、配置任务在job配置中选择gitlab connection:gitlab

在job配置界面
一、勾选 Build when a change is pushed to GitLab. GitLab CI Service URL: http://192.168.56.12:8080/project/php-deploy
二、选择push events 时间触发构建
三、选择分支过滤(此处能够根据不一样的需求来使用过滤功能)
四、secret token须要填入gitlab项目中的webhook

在gitlab中找到项目-->setting-->Integrations配置
填写在上图生成的连接:
URL:http://192.168.56.12:8080/project/php-deploy
Secret Token:3f199086a22c54957579966e34ad120a
点击Add webhook

测试是否生效:点击test-->选择push event会跳转到Hook excuted successfully:HTTP 200


在linux-node1上安装nginx,初始同步了线上代码,写入一个index.html。如图:
[root@linux-node1 ~]# ll /data/www/php-deploy/
total 12
-rw-r--r-- 1 root root 28 Dec 23 15:45 index.html
-rw-r--r-- 1 root root 12 Dec 21 16:11 new.html
-rw-r--r-- 1 root root 19 Dec 21 16:11 readme
[root@linux-node1 ~]# cat /data/www/php-deploy/index.html
<h1>welcome to beijing</h1>

模拟程序员在linux-node2上进行修改代码,并提交到gitlab的master分支上
[root@linux-node2 app1]# pwd
/root/php/app1
[root@linux-node2 app1]# echo "Welcome to use Jenkins and Gitlab" > index.html
[root@linux-node2 app1]# git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
#modified: index.html
#
no changes added to commit (use "git add" and/or "git commit -a")
[root@linux-node2 app1]# git add .
[root@linux-node2 app1]# git commit -m "jenkins + gitlab"
[master 7313bdd] jenkins + gitlab
1 file changed, 1 insertion(+), 1 deletion(-)
[root@linux-node2 app1]# git push origin master
Counting objects: 5, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 334 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@192.168.56.11:java/app1.git
dd37af6..7313bdd master -> master


到此,自动触发和发布就完成了!这只是一个简单的构建发布,做为内部测试使用仍是能够的!生产使用,有待优化!
1、环境说明和准备
一、环境说明
deploy-server |
192.168.56.12 |
发布 |
Centos 7.4 |
web |
192.168.56.13 |
web服务器,nfs服务器 |
Centos 7.4 |
二、服务器准备工做
(1)发布机前期准备
a.增长普通用户并配置密码
[root@deploy-server ~]
[root@deploy-server ~]
uid=1000(www) gid=1000(www) groups=1000(www)
[root@deploy-server ~]
[root@deploy-server ~]
b.建立部署须要的目录并初始化git目录
[root@deploy-server ~]
[root@deploy-server ~]
[www@deploy-server ~]$ tree /deploy
/deploy
├── code
│ ├── glzx
│ ├── gys
│ ├── jxs
│ ├── wap
│ ├── www
│ └── yyzx
├── config
├── tar
└── tmp
[www@deploy-server ~]$ cd /deploy/code/www && git init
c.建立配置文件config.php
[www@deploy-server ~]$ vim /deploy/config/config.php
this is config.php
[www@deploy-server ~]$ tree /deploy
/deploy
├── code
│ ├── glzx
│ ├── gys
│ ├── jxs
│ ├── wap
│ ├── www
│ └── yyzx
├── config
│ └── config.php
├── tar
└── tmp
d.配置发布机和目标机的ssh通讯
[www@deploy-server deploy]$ cat /home/www/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDzM3AW6/X+djvKJTsdFbY3ik+mlradxpD3COoTP5h6x509unksuCdduV7awPjEGHvK2GVjJmvckxdvLkMc23p7bsctHlturPN2VozJTrYwXMAbmxf97cKE/fpKhjPXG8HlWBLpEaTM8PITgvdcyaeAUaIN+/h5VrA8TZKFAgbxDLxtgwqPzYIG9nqCO7MMCgzhJxI6PDQ6KVU9rHal/p4XKTIy4Rq4FzZTav2tS4zNJ7kX9+e6EO0JTooPanJXBTltLOJJsKxnlA7tc20rq6+0XVqbUBKYahL/8ZzkxZozNrNq7wtIuuJo0WTDFzDdPcJyAGlRWLuwct7y4p4UApVz www@deploy-server
[www@deploy-server ~]$ ssh-copy-id www@192.168.56.13
/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/www/.ssh/id_rsa.pub"
The authenticity of host
ECDSA key fingerprint is SHA256:ahG6dBy/Z1nUIUWhQQrylsiwBlnDKC/jz8rnaPU2eF0.
ECDSA key fingerprint is MD5:6e:58:0b:02:1c:a4:41:51:e8:7d:33:4d:46:bb:a0:68.
Are you sure you want to continue connecting (yes/no)? yes
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
www@192.168.56.13
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'www@192.168.56.13'"
and check to make sure that only the key(s) you wanted were added.
[www@deploy-server ~]$ ssh 192.168.56.13
Last login: Fri Nov 2 18:01:02 2018
[www@web ~]$
e.将ssh公钥复制到github或gitlab

(2)web服务器准备
a.部署NFS服务器
[root@web ~]# yum install -y nfs-utils rpcbind
[root@web ~]# vim /etc/exports
/nas/www 192.168.56.0/24(rw,sync,no_root_squash)
/nas/jxs 192.168.56.0/24(rw,sync,no_root_squash)
/nas/wap 192.168.56.0/24(rw,sync,no_root_squash)
/nas/glzx 192.168.56.0/24(rw,sync,no_root_squash)
/nas/yyzx 192.168.56.0/24(rw,sync,no_root_squash)
/nas/gys 192.168.56.0/24(rw,sync,no_root_squash)
[root@web ~]# systemctl start rpcbind
[root@web ~]# systemctl start nfs
[root@web ~]# showmount -e
Export list for web:
/nas/gys 192.168.56.0/24
/nas/yyzx 192.168.56.0/24
/nas/glzx 192.168.56.0/24
/nas/wap 192.168.56.0/24
/nas/jxs 192.168.56.0/24
/nas/www 192.168.56.0/24
b.挂载共享目录
[root@web ~]
[root@web ~]
[root@web ~]
[root@web ~]
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 18G 1.7G 16G 10% /
devtmpfs 482M 0 482M 0% /dev
tmpfs 493M 0 493M 0% /dev/shm
tmpfs 493M 6.8M 486M 2% /run
tmpfs 493M 0 493M 0% /sys/fs/cgroup
/dev/sda1 497M 171M 326M 35% /boot
tmpfs 99M 0 99M 0% /run/user/0
192.168.56.13:/nas/www 18G 1.7G 16G 10% /webroot/www
c.部署nginx+php
[root@web ~]
[root@web ~]
[root@web ~]
[root@web ~]
user www;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
}
[root@web ~]
[root@web ~]
server {
listen 80;
server_name localhost;
root /data/web/www;
index index.php index.htm index.html;
client_max_body_size 20m;
location / {
proxy_read_timeout 150;
try_files $uri $uri/ /index.php; } location ~* .*\.php$ { #try_files $uri =404; include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
[root@web ~]
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@web ~]
[root@web ~]
user www
group www
....
[root@web ~]
[03-Nov-2018 10:16:18] NOTICE: configuration file /etc/php-fpm.conf test is successful
[root@web ~]
[root@web ~]
HTTP/1.1 200 OK
Server: nginx/1.12.2
Date: Sat, 03 Nov 2018 02:16:36 GMT
Content-Type: text/html
Content-Length: 35
Last-Modified: Sat, 03 Nov 2018 02:07:00 GMT
Connection: keep-alive
ETag: "5bdd02c4-23"
Accept-Ranges: bytes
2、发布脚本编写
一、自动化部署流程设计
- 发布机获取代码(直接拉取),从svn或git仓库进行拉取
- 发布机编译代码(可选,java语言须要编译,PHP无需编译)
- 将配置文件拷贝到代码文件(因为配置文件有数据库等机密信息,须要独立处理)
- 代码打包(将代码进行压缩打包)
- SCP到目标服务器目录
- 将目标服务器移除集群
- 在目标服务器上进行解压传过来的代码
- 解压后,对代码根目录进行软连接到刚才的目录文件,实现版本连接
- 重启(可选,tomcat须要重启)
- 测试
- 加入集群
二、自动化部署脚本编写
#!/bin/bash
NODE="192.168.56.13"
SHELL_NAME="deploy.sh"
SHELL_DIR="/home/www"
SHELL_LOG="${SHELL_DIR}/${SHELL_NAME}.log"
PRO_NAME="www"
CODE_DIR="/deploy/code/www"
CONFIG_DIR="/deploy/config"
TMP_DIR="/deploy/tmp"
TAR_DIR="deploy/tar"
LOCK_FILE="/tmp/deploy.lock"
LOG_DATE='date "+%Y-%m-%d"'
LOG_TIME='date "+%H-%M-%S"'
CDATE=$(date "+%Y-%m-%d")
CTIME=$(date "+%H-%M-%S")
useage(){
echo $"Useage: $0 { deploy |rollback [ list | version ] }"
}
url_test(){
URL=$1
curl -s --head $URL |grep '200 OK'
if [ $? -ne 0 ];then
shell_unlock;
writelog "test error" && exit;
fi
}
writelog(){
LOGINFO=$1
echo "${CDATE} ${CTIME}: ${SHELL_NAME} : ${LOGINFO} " >> ${SHELL_LOG}
}
code_get(){
writelog "code_get";
cd ${CODE_DIR} && git pull git@github.com:kin08200/learngit.git
cp -r ${CODE_DIR} ${TMP_DIR}
API_VERL=$(git show |grep commit |cut -d ' ' -f2 )
API_VER=$(echo ${API_VERL:0:6})
echo $API_VER
}
code_config(){
writelog "code_config"
/bin/cp -r ${CONFIG_DIR}/* ${TMP_DIR}/${PRO_NAME}
PKG_NAME=${PRO_NAME}_"${API_VER}"_"${CDATE}-${CTIME}"
cd ${TMP_DIR} && mv ${PRO_NAME} ${PKG_NAME}
}
code_tar(){
writelog "code_tar"
cd ${TMP_DIR} && tar -czf ${PKG_NAME}.tar.gz ${PKG_NAME}
writelog "${PKG_NAME}.tar.gz"
}
code_scp(){
writelog "code_scp"
scp ${TMP_DIR}/${PKG_NAME}.tar.gz $NODE:/webroot/www
}
code_deploy(){
writelog "code_deploy"
ssh $NODE "cd /webroot/www && tar -zxf ${PKG_NAME}.tar.gz"
ssh $NODE "rm -rf /data/web/www && ln -s /webroot/www/${PKG_NAME} /data/web/www"
}
code_test(){
url_test "http://192.168.56.13"
}
rollback_fun(){
ssh $NODE "rm -rf /data/web/www && ln -s /webroot/www/$1 /data/web/www"
}
rollback(){
if [ -z $1 ];then
shell_unlock;
echo "Please input rollback version." && exit;
fi
case $1 in
list)
ls -l /deploy/tmp/*.tar.gz
;;
*)
rollback_fun $1
;;
esac
}
shell_lock(){
touch ${LOCK_FILE}
}
shell_unlock(){
rm -f ${LOCK_FILE}
}
main(){
if [ -f ${LOCK_FILE} ];then
echo "Deploy is running" && exit
fi
DEPLOY_METHOD=$1
ROLLBACK_VER=$2
case $DEPLOY_METHOD in
deploy)
shell_lock;
code_get;
code_config;
code_tar;
code_scp;
code_deploy;
code_test;
shell_unlock;
;;
rollback)
shell_lock;
rollback $ROLLBACK_VER;
shell_unlock;
;;
*)
useage;
;;
esac
}
main $1 $2
3、发布测试
一、开发机和github添加ssh信任
[www@localhost ~]$ cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+ta7tkljnIgqvgEugQvIfVxH/a+geX250ZhOpe+14Q8EBQSI+qGyXCeihln+0aQpzIERvNBZ7JjWCg5XeQlgPBgCmqoQKNTWl/NUBT+uY/NY9fIGdRCVBvVcDC554Be48zB57mtapKQEkqm/8kmq7sPRQDv98l5wvFvYOPxocmjnioDZr3GeYmgdFPNJ5WGg6yY29IHXgh2v3eCXLwX2Z2eUdKCpV1LS42wdAN8TqHFCEmthREIq2r86ZKPOovD6Micq7wa2yJqtA/hkv+DvEhRzOIVznfW5EptOyKYcittGu63JGMSbCr1uCdW7PLUQ8aIWDDlip+/EcIt0KkuJJ www@localhost.localdomain
二、克隆项目到开发机进行开发测试
[www@localhost ~]$ mkdir dev && cd dev
[www@localhost dev]$ git clone git@github.com:kin08200/learngit.git
[www@localhost dev]$ ll
total 4
drwxrwxr-x 3 www www 4096 Nov 2 22:02 learngit
[www@localhost dev]$ cd learngit
三、修改index.html文件
[www@localhost learngit]$ ll
total 8
-rw-rw-r-- 1 www www 0 Nov 2 04:31 123
-rw-rw-r-- 1 www www 35 Nov 2 22:02 index.html
-rw-rw-r-- 1 www www 80 Nov 2 04:31 readme.txt
[www@localhost learngit]$ echo "<h1> welcome to Beijing </h1>" > index.html
四、提交代码
[www@localhost learngit]$ git add .
[www@localhost learngit]$ git commit -m "modify index.html"
[www@localhost learngit]$ git push origin master
五、发布代码
[www@deploy-server ~]$ ./deploy.sh deploy
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From github.com:kin08200/learngit
* branch HEAD -> FETCH_HEAD
Updating 9a781b2..683a440
Fast-forward
index.html | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
683a44
www_683a44_2018-11-03-10-06-56.tar.gz 100% 22KB 9.3MB/s 00:00
HTTP/1.1 200 OK
六、测试访问
[www@deploy-server ~]$ curl 192.168.56.13
<h1>
welcome to Beijing!!!!
</h1>
七、回滚测试
[root@web ~]# ll /data/web/
total 0
lrwxrwxrwx 1 www www 43 Nov 3 10:46 www -> /webroot/www/www_683a44_2018-11-03-10-06-56
测试访问以下,下面进行查看版本列表,并选择回滚到www_9a781b_2018-11-03-09-59-44版本

[www@deploy-server ~]$ ./deploy.sh rollback list
-rw-rw-r
-rw-rw-r
-rw-rw-r
-rw-rw-r
-rw-rw-r
-rw-rw-r
[www@deploy-server ~]$ ./deploy.sh rollback www_9a781b_2018-11-03-09-59-44
[root@web ~]# ll /data/web/
total 0
lrwxrwxrwx 1 www www 43 Nov 3 10:48 www -> /webroot/www/www_9a781b_2018-11-03-09-59-44
再进行访问测试:
