怎样做自适应网站宁波 seo排名公司
Jenkins参数化构建
- web服务器
- jenkins服务器
- 编写主机清单
- 编写脚本代码
- jenkins服务web页面操作
web服务器
下载nginx
下载gitcd /usr/share/nginxrm -rf htmlgit clone http://root:Qq123456@192.168.188.176/ximu/test-nginx.gitmv test-nginx/ html
jenkins服务器
下载ansible
编写主机清单
vim /opt/hosts
[nginx]
web服务器ip
编写脚本代码
vim ansible.sh#/bin/bash
SERVICE_NAME=$1
SERVICE_STATUS=$2
GITLAB_CODE=$3
GITLAB_ID=$4HOSTFILE=/opt/hostsCMD="ansible -i $HOSTFILE $1"if [ $SERVICE_NAME = "nginx" ];thenif [ $GITLAB_CODE = "pull" ];then$CMD -m shell -a 'chdir=/usr/share/nginx/html git pull origin main'elif [ $GITLAB_CODE = "reset1" ];then$CMD -m shell -a 'chdir=/usr/share/nginx/html git reset --hard HEAD^'elif [ $GITLAB_CODE = "reset2" ];then$CMD -m shell -a 'chdir=/usr/share/nginx/html git reset --hard HEAD^^'elif [ $GITLAB_CODE = "reset_id" ];then$CMD -m shell -a "chdir=/usr/share/nginx/html git reset --hard $GITLAB_ID"fiif [ $SERVICE_STATUS != "none" ] ;thensystemctl $SERVICE_STATUS nginxfi
fi
jenkins服务web页面操作