linux系统Jenkins工具参数化构建

Jenkins参数化构建

web服务器

下载nginx
下载git

cd /usr/share/nginx

rm -rf html

git clone http://root:Qq123456@192.168.188.176/ximu/test-nginx.git

mv 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=$4

HOSTFILE=/opt/hosts

CMD="ansible -i $HOSTFILE $1"


if [ $SERVICE_NAME = "nginx" ];then
  if [ $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"
  fi
  if [ $SERVICE_STATUS != "none" ]  ;then
    systemctl $SERVICE_STATUS nginx
  fi
fi

jenkins服务web页面操作









相关推荐
陆鳐LuLu26 分钟前
日志管理利器:基于 ELK 的日志收集、存储与可视化实战
运维·elk·jenkins
CodeWithMe40 分钟前
[ Vim ] 常用命令 and 配置
linux·编辑器·vim
DC_BLOG44 分钟前
Linux-GlusterFS进阶分布式卷
linux·运维·服务器·分布式
[奋斗不止]1 小时前
Jenkins 配置 Credentials 凭证
jenkins·jenkins 配置凭证
cookies_s_s1 小时前
Linux--进程(进程虚拟地址空间、页表、进程控制、实现简易shell)
linux·运维·服务器·数据结构·c++·算法·哈希算法
丁劲犇2 小时前
碳基生物的悲歌-DeepSeek思考实现Linux动态库递归收集工具
linux·递归·deepseek·ldd
zhouwu_linux2 小时前
MT7628基于原厂的SDK包, 修改ra1网卡的MAC方法。
linux·运维·macos
2401_897930062 小时前
linux系统如何配置host.docker.internal
linux·docker·eureka
诶尔法Alpha2 小时前
Linux上使用dify构建RAG
linux·运维·服务器
熬夜苦读学习3 小时前
Linux文件系统
linux·运维·服务器·开发语言·后端