#!/bin/sh
# by wangke
# 用户输入自定义信息
read -p "请输入你想修改的环境(DEBUG、QA、ST):" env
read -p "请输入当前正在使用的分支:" now_branch
read -p "请输入你修改后使用的分支:" new_branch
echo 你选择的环境是:\"$env\" 你想要将\""$now_branch"\"分支替换成\""$new_branch"\"分支
sleep 1
# 用户确认
read -p "确认你的输入:继续请输入:Y,退出请输入任意键:" input1
if [ $input1 != "Y" ];then
echo "Bye-bye!"
exit 0
fi
# 修改DEBUG环境
if [ $env = "DEBUG" ];then
for list in `find /root/.jenkins/jobs/DEBUG-UZAO-*/ -maxdepth 1 -type f -name config.xml`;do sed -i s/$now_branch/$new_branch/g $list;done
sleep 1
echo ">>>>>>>>>>>>>>>>>>>>>修改成功-正在重载Jenkins配置<<<<<<<<<<<<<<<<<<<<<<<<<<"
curl -X POST http://192.168.2.191:8080/jenkins/reload --user root:'jks2016!@#'
fi
# 修改QA环境
if [ $env = "QA" ];then
for list in `find /root/.jenkins/jobs/QA-UZAO-*/ -maxdepth 1 -type f -name config.xml`;do sed -i s/$now_branch/$new_branch/g $list;done
sleep 1
echo ">>>>>>>>>>>>>>>>>>>>>修改成功-正在重载Jenkins配置<<<<<<<<<<<<<<<<<<<<<<<<<<"
sleep 1
curl -X POST http://192.168.2.191:8080/jenkins/reload --user root:'jks2016!@#'
fi
# 修改ST环境
if [ $env = "ST" ];then
for list in `find /root/.jenkins/jobs/ST-UZAO-*/ -maxdepth 1 -type f -name config.xml`;do sed -i s/$now_branch/$new_branch/g $list;done
sleep 1
echo ">>>>>>>>>>>>>>>>>>>>>修改成功-正在重载Jenkins配置<<<<<<<<<<<<<<<<<<<<<<<<<<"
sleep 1
curl -X POST http://192.168.2.191:8080/jenkins/reload --user root:'jks2016!@#'
fi