jenkins+shell自动构建php和golang的环境

第一次写shell,如有不妥之处还请多多指教,O(∩_∩)O哈哈~

#!/bin/bash
//设置服务器解压包的路径
golang_path='/var/www/project1'
php_path='/var/www/project2'
temp_path='/root/temp' //压缩包存放路径
filename=test.tar.gz
cd $temp_path //进入压缩包存放路径(从jenkins服务器发过来的)

if [ "$1" = "golang_path" ] //如果是golang的包,执行以下操作
then
	cp $file $golang_path //取包并清理源文件
	rm -fr *
	cd $golang_path //解压到目标路径并清理源文件
	tar -zxf $file
	rm -fr $file
	go build //golang的build
	supervisor restart all //重启golang服务
	supervisor status //查看golang服务状态
elif [ "$1" = "php_path" ] //如果是php的包,执行以下操作
then
	cp $file $php_path //取包并清理源文件
	rm -fr *
	cd $php_path //解压到目标路径并清理源文件
	tar -zxf $file
	rm -fr $file
	chmod -R 777 * //赋予执行权限
	cd $php_path/server
	php artisan route:cache //清楚缓存,更新数据库
	php artisan cache:clear
	php artisan migrate
	cd ../admin //部署前端代码
	npm install
	npm run build
fi

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值