git 自動上傳程式碼到遠端倉庫
自動上傳應用程式碼到git倉庫中。具體詳見程式碼。
if [[ $1 = "--help" ]] || [[ $1 = "-h" ]]
then
echo "1、專案名稱請選擇以下定義好的名稱"
echo "
社保專案 :newsx、sxzw、reporting、reportingSYN、
微服務vspn30 :eapi 、fxkz、jdjc、screen、zwgl、service
"
echo "2、升級環境請選擇以下定義好的名稱"
echo "
生產環境 : prod
開發環境 : dev
"
echo "3、升級包位置請輸入上傳升級包存放的位置"
echo "
示例 : /z/02升級補丁包/01newsx/20210401/newsx
"
exit 0
fi
read -p "請輸入專案名稱:" project
read -rp "請輸入升級包位置:" sjpath_bat
read -p "請輸入升級環境:" sjenv
echo "----------------------------------"
echo -e "\033[0;31;1m輸入的專案名稱為:${project}\033[0m"
echo -e "\033[0;31;1m輸入的升級包位置為: ${sjpath_bat}\033[0m"
echo -e "\033[0;31;1m輸入的升級環境為:${sjenv}\033[0m"
echo "----------------------------------"
riqi=`date +'%Y%m%d'`
riqitime=`date +'%Y%m%d_%H%M%S'`
sjpath=$(echo $sjpath_bat |sed -e 's/\\/\//g'|sed -e 's/z:/\/z/')
echo $sjpath
if [ $sjenv == 'dev' ];then
cd /z/01業務升級/dev/
if [ $project == 'newsx' ];then
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"
cd newsx
git checkout -B "dev_newsx_$riqi"
cp -rf $sjpath /z/01業務升級/dev
if [ $? == 0 ];then
echo -e "\033[42m升級檔案複製成功!!!\033[0m"
else
echo -e "\033[41m升級檔案複製失敗!!!\033[0m"
exit 1
fi
git add .
git commit -m "Push Code: dev_newsx_$riqitime"
git push --set-upstream origin "dev_newsx_$riqi"
echo -e "\033[45m 分支名稱為:dev_newsx_$riqi \033[0m"
echo -e "\033[45m Commit ID:dev_newsx_$riqitime \033[0m"
echo -e "\033[42m 上傳升級完到gitlab成功!!\033[0m"
elif [ $project == 'sxzw' ];then
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"
cd sxzw
git checkout -B "dev_sxzw_$riqi"
cp -rf $sjpath /z/01業務升級/dev
if [ $? == 0 ];then
echo -e "\033[42m升級檔案複製成功!!!\033[0m"
else
echo -e "\033[41m升級檔案複製失敗!!!\033[0m"
exit 1
fi
git add .
git commit -m "Push Code: dev_sxzw_$riqitime"
git push --set-upstream origin "dev_sxzw_$riqi"
echo -e "\033[45m 分支名稱為:dev_sxzw_$riqi \033[0m"
echo -e "\033[45m Commit ID:dev_sxzw_$riqitime \033[0m"
echo -e "\033[42m 上傳升級完到gitlab成功!!\033[0m"
elif [ $project == 'reporting' ];then
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"
cd reporting
git checkout -B "dev_reporting_$riqi"
cp -rf $sjpath /z/01業務升級/dev
if [ $? == 0 ];then
echo -e "\033[42m升級檔案複製成功!!!\033[0m"
else
echo -e "\033[41m升級檔案複製失敗!!!\033[0m"
exit 1
fi
git add .
git commit -m "Push Code: dev_reporting_$riqitime"
git push --set-upstream origin "dev_reporting_$riqi"
echo -e "\033[45m 分支名稱為:dev_reporting_$riqi \033[0m"
echo -e "\033[45m Commit ID:dev_reporting_$riqitime \033[0m"
echo -e "\033[42m 上傳升級完到gitlab成功!!\033[0m"
elif [ $project == 'reportingSYN' ];then
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"
cd reportingSYN
git checkout -B "dev_reportingSYN_$riqi"
cp -rf $sjpath /z/01業務升級/dev
if [ $? == 0 ];then
echo -e "\033[42m升級檔案複製成功!!!\033[0m"
else
echo -e "\033[41m升級檔案複製失敗!!!\033[0m"
exit 1
fi
git add .
git commit -m "Push Code: dev_reportingSYN_$riqitime"
git push --set-upstream origin "dev_reportingSYN_$riqi"
echo -e "\033[45m 分支名稱為:dev_reportingSYN_$riqi \033[0m"
echo -e "\033[45m Commit ID:dev_reportingSYN_$riqitime \033[0m"
echo -e "\033[42m 上傳升級完到gitlab成功!!\033[0m"
elif [ $project == 'eapi' ];then
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"
cd vspn30-eapi
git checkout -B "dev_eapi_$riqi"
cp -rf $sjpath /z/01業務升級/dev
if [ $? == 0 ];then
echo -e "\033[42m升級檔案複製成功!!!\033[0m"
else
echo -e "\033[41m升級檔案複製失敗!!!\033[0m"
exit 1
fi
git add .
git commit -m "Push Code: dev_eapi_$riqitime"
git push --set-upstream origin "dev_eapi_$riqi"
echo -e "\033[45m 分支名稱為:dev_eapi_$riqi \033[0m"
echo -e "\033[45m Commit ID:dev_eapi_$riqitime \033[0m"
echo -e "\033[42m 上傳升級完到gitlab成功!!\033[0m"
elif [ $project == 'fxkz' ];then
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"
cd vspn30-fxkz
git checkout -B "dev_fxkz_$riqi"
cp -rf $sjpath /z/01業務升級/dev
if [ $? == 0 ];then
echo -e "\033[42m升級檔案複製成功!!!\033[0m"
else
echo -e "\033[41m升級檔案複製失敗!!!\033[0m"
exit 1
fi
git add .
git commit -m "Push Code: dev_fxkz_$riqitime"
git push --set-upstream origin "dev_fxkz_$riqi"
echo -e "\033[45m 分支名稱為:dev_fxkz_$riqi \033[0m"
echo -e "\033[45m Commit ID:dev_fxkz_$riqitime \033[0m"
echo -e "\033[42m 上傳升級完到gitlab成功!!\033[0m"
elif [ $project == 'jdjc' ];then
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"
cd vspn30-jdjc
git checkout -B "dev_jdjc_$riqi"
cp -rf $sjpath /z/01業務升級/dev
if [ $? == 0 ];then
echo -e "\033[42m升級檔案複製成功!!!\033[0m"
else
echo -e "\033[41m升級檔案複製失敗!!!\033[0m"
exit 1
fi
git add .
git commit -m "Push Code: dev_jdjc_$riqitime"
git push --set-upstream origin "dev_jdjc_$riqi"
echo -e "\033[45m 分支名稱為:dev_jdjc_$riqi \033[0m"
echo -e "\033[45m Commit ID:dev_jdjc_$riqitime \033[0m"
echo -e "\033[42m 上傳升級完到gitlab成功!!\033[0m"
elif [ $project == 'screen' ];then
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"
cd vspn30-screen
git checkout -B "dev_screen_$riqi"
cp -rf $sjpath /z/01業務升級/dev
if [ $? == 0 ];then
echo -e "\033[42m升級檔案複製成功!!!\033[0m"
else
echo -e "\033[41m升級檔案複製失敗!!!\033[0m"
exit 1
fi
git add .
git commit -m "Push Code: dev_screen_$riqitime"
git push --set-upstream origin "dev_screen_$riqi"
echo -e "\033[45m 分支名稱為:dev_screen_$riqi \033[0m"
echo -e "\033[45m Commit ID:dev_screen_$riqitime \033[0m"
echo -e "\033[42m 上傳升級完到gitlab成功!!\033[0m"
elif [ $project == 'zwgl' ];then
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"
cd vspn30-zwgl
git checkout -B "dev_zwgl_$riqi"
cp -rf $sjpath /z/01業務升級/dev
if [ $? == 0 ];then
echo -e "\033[42m升級檔案複製成功!!!\033[0m"
else
echo -e "\033[41m升級檔案複製失敗!!!\033[0m"
exit 1
fi
git add .
git commit -m "Push Code: dev_zwgl_$riqitime"
git push --set-upstream origin "dev_zwgl_$riqi"
echo -e "\033[45m 分支名稱為:dev_zwgl_$riqi \033[0m"
echo -e "\033[45m Commit ID:dev_zwgl_$riqitime \033[0m"
echo -e "\033[42m 上傳升級完到gitlab成功!!\033[0m"
elif [ $project == 'service' ];then
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"
cd vst-service
git checkout -B "dev_service_$riqi"
cp -rf $sjpath /z/01業務升級/dev
if [ $? == 0 ];then
echo -e "\033[42m升級檔案複製成功!!!\033[0m"
else
echo -e "\033[41m升級檔案複製失敗!!!\033[0m"
exit 1
fi
git add .
git commit -m "Push Code: dev_service_$riqitime"
git push --set-upstream origin "dev_service_$riqi"
echo -e "\033[45m 分支名稱為:dev_service_$riqi \033[0m"
echo -e "\033[45m Commit ID:dev_service_$riqitime \033[0m"
echo -e "\033[42m 上傳升級完到gitlab成功!!\033[0m"
else
echo "輸入的專案名稱不存在,請執行 sh git.sh --help 檢視具體專案名稱!!"
fi
elif [ $sjenv == 'prod' ];then
cd /z/01業務升級/product/
if [ $project == 'newsx' ];then
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"
cd newsx
git checkout -B "prod_newsx_$riqi"
cp -rf $sjpath /z/01業務升級/product
if [ $? == 0 ];then
echo -e "\033[42m升級檔案複製成功!!!\033[0m"
else
echo -e "\033[41m升級檔案複製失敗!!!\033[0m"
exit 1
fi
git add .
git commit -m "Push Code: prod_newsx_$riqitime"
git push --set-upstream origin "prod_newsx_$riqi"
echo -e "\033[45m 分支名稱為:prod_newsx_$riqi \033[0m"
echo -e "\033[45m Commit ID:prod_newsx_$riqitime \033[0m"
echo -e "\033[42m 上傳升級完到gitlab成功!!\033[0m"
elif [ $project == 'sxzw' ];then
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"
cd sxzw
git checkout -B "prod_sxzw_$riqi"
cp -rf $sjpath /z/01業務升級/product
if [ $? == 0 ];then
echo -e "\033[42m升級檔案複製成功!!!\033[0m"
else
echo -e "\033[41m升級檔案複製失敗!!!\033[0m"
exit 1
fi
git add .
git commit -m "Push Code: prod_sxzw_$riqitime"
git push --set-upstream origin "prod_sxzw_$riqi"
echo -e "\033[45m 分支名稱為:prod_sxzw_$riqi \033[0m"
echo -e "\033[45m Commit ID:prod_sxzw_$riqitime \033[0m"
echo -e "\033[42m 上傳升級完到gitlab成功!!\033[0m"
elif [ $project == 'reporting' ];then
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"
cd reporting
git checkout -B "prod_reporting_$riqi"
cp -rf $sjpath /z/01業務升級/product
if [ $? == 0 ];then
echo -e "\033[42m升級檔案複製成功!!!\033[0m"
else
echo -e "\033[41m升級檔案複製失敗!!!\033[0m"
exit 1
fi
git add .
git commit -m "Push Code: prod_reporting_$riqitime"
git push --set-upstream origin "prod_reporting_$riqi"
echo -e "\033[45m 分支名稱為:prod_reporting_$riqi \033[0m"
echo -e "\033[45m Commit ID:prod_reporting_$riqitime \033[0m"
echo -e "\033[42m 上傳升級完到gitlab成功!!\033[0m"
elif [ $project == 'reportingSYN' ];then
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"
cd reportingSYN
git checkout -B "prod_reportingSYN_$riqi"
cp -rf $sjpath /z/01業務升級/product
if [ $? == 0 ];then
echo -e "\033[42m升級檔案複製成功!!!\033[0m"
else
echo -e "\033[41m升級檔案複製失敗!!!\033[0m"
exit 1
fi
git add .
git commit -m "Push Code: prod_reportingSYN_$riqitime"
git push --set-upstream origin "prod_reportingSYN_$riqi"
echo -e "\033[45m 分支名稱為:prod_reportingSYN_$riqi \033[0m"
echo -e "\033[45m Commit ID:prod_reportingSYN_$riqitime \033[0m"
echo -e "\033[42m 上傳升級完到gitlab成功!!\033[0m"
elif [ $project == 'eapi' ];then
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"
cd vspn30-eapi
git checkout -B "prod_eapi_$riqi"
cp -rf $sjpath /z/01業務升級/product
if [ $? == 0 ];then
echo -e "\033[42m升級檔案複製成功!!!\033[0m"
else
echo -e "\033[41m升級檔案複製失敗!!!\033[0m"
exit 1
fi
git add .
git commit -m "Push Code: prod_eapi_$riqitime"
git push --set-upstream origin "prod_eapi_$riqi"
echo -e "\033[45m 分支名稱為:prod_eapi_$riqi \033[0m"
echo -e "\033[45m Commit ID:prod_eapi_$riqitime \033[0m"
echo -e "\033[42m 上傳升級完到gitlab成功!!\033[0m"
elif [ $project == 'fxkz' ];then
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"
cd vspn30-fxkz
git checkout -B "prod_fxkz_$riqi"
cp -rf $sjpath /z/01業務升級/product
if [ $? == 0 ];then
echo -e "\033[42m升級檔案複製成功!!!\033[0m"
else
echo -e "\033[41m升級檔案複製失敗!!!\033[0m"
exit 1
fi
git add .
git commit -m "Push Code: prod_fxkz_$riqitime"
git push --set-upstream origin "prod_fxkz_$riqi"
echo -e "\033[45m 分支名稱為:prod_fxkz_$riqi \033[0m"
echo -e "\033[45m Commit ID:prod_fxkz_$riqitime \033[0m"
echo -e "\033[42m 上傳升級完到gitlab成功!!\033[0m"
elif [ $project == 'jdjc' ];then
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"
cd vspn30-jdjc
git checkout -B "prod_jdjc_$riqi"
cp -rf $sjpath /z/01業務升級/product
if [ $? == 0 ];then
echo -e "\033[42m升級檔案複製成功!!!\033[0m"
else
echo -e "\033[41m升級檔案複製失敗!!!\033[0m"
exit 1
fi
git add .
git commit -m "Push Code: prod_jdjc_$riqitime"
git push --set-upstream origin "prod_jdjc_$riqi"
echo -e "\033[45m 分支名稱為:prod_jdjc_$riqi \033[0m"
echo -e "\033[45m Commit ID:prod_jdjc_$riqitime \033[0m"
echo -e "\033[42m 上傳升級完到gitlab成功!!\033[0m"
elif [ $project == 'screen' ];then
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"
cd vspn30-screen
git checkout -B "prod_screen_$riqi"
cp -rf $sjpath /z/01業務升級/product
if [ $? == 0 ];then
echo -e "\033[42m升級檔案複製成功!!!\033[0m"
else
echo -e "\033[41m升級檔案複製失敗!!!\033[0m"
exit 1
fi
git add .
git commit -m "Push Code: prod_screen_$riqitime"
git push --set-upstream origin "prod_screen_$riqi"
echo -e "\033[45m 分支名稱為:prod_screen_$riqi \033[0m"
echo -e "\033[45m Commit ID:prod_screen_$riqitime \033[0m"
echo -e "\033[42m 上傳升級完到gitlab成功!!\033[0m"
elif [ $project == 'zwgl' ];then
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"
cd vspn30-zwgl
git checkout -B "prod_zwgl_$riqi"
cp -rf $sjpath /z/01業務升級/product
if [ $? == 0 ];then
echo -e "\033[42m升級檔案複製成功!!!\033[0m"
else
echo -e "\033[41m升級檔案複製失敗!!!\033[0m"
exit 1
fi
git add .
git commit -m "Push Code: prod_zwgl_$riqitime"
git push --set-upstream origin "prod_zwgl_$riqi"
echo -e "\033[45m 分支名稱為:prod_zwgl_$riqi \033[0m"
echo -e "\033[45m Commit ID:prod_zwgl_$riqitime \033[0m"
echo -e "\033[42m 上傳升級完到gitlab成功!!\033[0m"
elif [ $project == 'service' ];then
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"
cd vst-service
git checkout -B "prod_service_$riqi"
cp -rf $sjpath /z/01業務升級/product
if [ $? == 0 ];then
echo -e "\033[42m升級檔案複製成功!!!\033[0m"
else
echo -e "\033[41m升級檔案複製失敗!!!\033[0m"
exit 1
fi
git add .
git commit -m "Push Code: prod_service_$riqitime"
git push --set-upstream origin "prod_service_$riqi"
echo -e "\033[45m 分支名稱為:prod_service_$riqi \033[0m"
echo -e "\033[45m Commit ID:prod_service_$riqitime \033[0m"
echo -e "\033[42m 上傳升級完到gitlab成功!!\033[0m"
else
echo "輸入的專案名稱不存在,請執行 sh git.sh --help 檢視具體專案名稱!!"
fi
else
echo "輸入升級環境不存在,請選擇生產環境(prod) 或者 開發環境(dev)"
fi
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30345407/viewspace-2766382/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- git push到遠端倉庫Git
- git 從遠端倉庫指定分支clone程式碼到本地Git
- git 本地push到遠端倉庫Git
- git 遠端倉庫Git
- git倉庫修改遠端倉庫Git
- Git更改遠端程式碼倉地址Git
- Git同步兩個遠端倉庫的分支程式碼Git
- 使用GitBash從Git遠端倉庫下載程式碼Git
- git-遠端倉庫Git
- Git 使用遠端倉庫Git
- Visual Studio使用Git忽略不想上傳到遠端倉庫的檔案Git
- git 修改本地倉庫的遠端倉庫地址Git
- git上傳到遠端有部分檔案未上傳Git
- Linux構建Git程式碼倉庫與自動部署LinuxGit
- IDEA更改遠端git倉庫地址IdeaGit
- 如何修改 Git 遠端倉庫 URLGit
- 本地倉庫推送到遠端倉庫的git操作Git
- Git強制推送程式碼到遠端Git
- git使用步驟——斷開與原來遠端倉庫的連線,連線新倉庫並上傳Git
- git連線遠端倉庫的方式Git
- 修改git遠端倉庫分支名稱Git
- Git remote 遠端倉庫連結管理GitREM
- git 入門教程之遠端倉庫Git
- git克隆遠端倉庫的指定分支Git
- 【git】強制覆蓋原生程式碼(與git遠端倉庫保持一致)Git
- idea開發工具配置git,連線到gitee遠端倉庫IdeaGitee
- 如何完整遷移git倉庫到另一個遠端地址Git
- 【Git】fork遠端倉庫,fork倉庫同步和提交pull requestGit
- Git 系列教程(8)- 遠端倉庫的使用Git
- 教你玩轉Git-提取遠端倉庫Git
- git 從遠端倉庫獲取所有分支Git
- Git使用小技巧之多個遠端倉庫Git
- 如何把原生程式碼推送到遠端倉庫
- git常用命令及手動關聯git本地和遠端倉庫Git
- 自動同步 Github 倉庫到 Gitee 倉庫GithubGitee
- cmake使用教程(十一)-使用cpack打包原始碼並編寫自動化指令碼上傳到倉庫原始碼指令碼
- 【第十篇】- Git 遠端倉庫(Github)Github
- 教你玩轉Git-刪除遠端倉庫Git