本文共 1414 字,大约阅读时间需要 4 分钟。
#!/bin/sh# #by wangke# 用户输入自定义信息read -p "请输入你想修改的环境(DEBUG、QA、ST):" envread -p "请输入当前正在使用的分支:" now_branchread -p "请输入你修改后使用的分支:" new_branchecho 你选择的环境是:\"$env\" 你想要将\""$now_branch"\"分支替换成\""$new_branch"\"分支sleep 1# 用户确认read -p "确认你的输入:继续请输入:Y,退出请输入任意键:" input1if [ $input1 != "Y" ];then echo "Bye-bye!" exit 0fi# 修改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
转载于:https://blog.51cto.com/wangxiaoke/2176146