一、maven项目
1.复制配制文件
#!/bin/bash
echo "复制配置文件..."
cp -fr /var/lib/jenkins/workspace/hms-background.te/config/* /var/lib/jenkins/workspace/hms-background.te/src/
2. 部署到tomcat
二、部署nodeJS项目
1、构建配置
#!/bin/bash echo -n "当前路径:" pwd echo "环境变量: ${PATH}" echo -n "node版本:" node -v echo -n "npm版本:" npm -v echo "开始安装..." npm install --registry=https://registry.npm.taobao.org echo "删除上一次构建..." rm -rf ./dist/* echo "开始编译..." npm run build:prod echo "编译完成." echo "开始打包..." cd dist echo -n "当前路径:" pwd tar -zcvf dist.tar.gz * echo "打包完成."
2、部署nginx配置
#!/bin/bash
echo "开始关闭nginx..."
/etc/rc.d/init.d/nginx stop
echo "成功关闭nginx."
echo "删除原项目文件..."
rm -rf /www/wwwroot/ruoyi-cli.com/*
echo "拷贝dist.tar.gz文件到nginx项目路径"
cp -f /www/jenkins/hms-front/dist.tar.gz /www/wwwroot/ruoyi-cli.com/
echo "解压dist.tar.gz文件"
cd /www/wwwroot/ruoyi-cli.com/ && tar -xvf dist.tar.gz
echo "删除dist.tar.gz文件..."
rm -f /www/wwwroot/ruoyi-cli.com/dist.tar.gz
echo "开始启动nginx..."
/etc/rc.d/init.d/nginx start
echo "nginx启动成功."