rancher2.1.7 +jenkins +harbor 自動容器CI系統(經過rancher命令行)

jenkins腳本執行示例:docker

//環境定義與gradle

cd $WORKSPACE
module=news-user
cd $module/
case $deploy in
deploy) //發佈模塊ui

//編譯
/opt/gradle/bin/gradle clean
/opt/gradle/bin/gradle bootRepackagetoken

//打包
docker build -t reg.***.com/news-qa/$module:$BUILD_NUMBER .jenkins

//上傳鏡像庫
docker login -u*** -p*** reg.***.com
docker push reg.***.com/news-qa/$module:$BUILD_NUMBERit

//清除打包鏡像
docker rmi --force `docker images |grep $module|awk '{print $3}'`io

//登陸rancher 集羣並切換至須要更新的項目
/usr/local/bin/rancher login https://ranchertest.****.com/v3 --token token-zj759:****** --context c-cmfdk:p-htkzp編譯

//更新指定的POD
/usr/local/bin/rancher kubectl set image deploy $module $module=reg.***.com/news-qa/$module:$BUILD_NUMBER -n news-qa1
;;test

//回滾
rollback)
echo "rollback"
echo "rollback version:$version"集羣

//回滾至指定的版本 /usr/local/bin/rancher login https://ranchertest.****.com/v3 --token token-zj759:****** --context c-cmfdk:p-htkzp /usr/local/bin/rancher kubectl set image deploy $module $module=reg.*****.com/news-qa/$module:$version -n news-qa1 ;;*) exit ;;esac

相關文章
相關標籤/搜索