1.? 丟棄舊的構建
2. 是否需要install
?3. git
4. 配置node16:
?5. 腳本:
文章來源:http://www.zghlxwxcb.cn/news/detail-781191.html
腳本:文章來源地址http://www.zghlxwxcb.cn/news/detail-781191.html
#進入Jenkins工作空間下項目目錄
cd /var/lib/jenkins/workspace/你的任務名稱
node -v #檢測node版本(此條命令非必要)
npm -v #檢測npm版本(此條命令非必要)
npm config set registry https://registry.npm.taobao.org #把npm源設置為淘寶源(這個你懂的)
npm config get registry #檢測npm是否切換成功(此條命令非必要)
#!/bin/bash
if [ "${need_install}" = "true" ];then
echo "準備更新倉庫"
npm install --legacy-peer-deps
fi
#打包
npm run build:prod
# 防止npm run build 報錯,shell不繼續(xù)執(zhí)行,直接返回 exit 0
exit 0
cd dist
pwd
#刪除上次打包生成的壓縮文件(一般建議備份,不要直接刪除,這邊測試就無所謂啦)
rm -rf test.tar.gz
#把生成的項目打包成壓縮包,方便移動到項目部署目錄
tar -zcvf test.tar.gz *
cd /usr/local/nginx/html #進入web項目根目錄
echo "當前操作人"
whoami
mv /var/lib/jenkins/workspace/你的任務名稱/dist/test.tar.gz ./ #移動剛剛打包好的項目到web項目根目錄
pwd
mkdir dist
tar -zxvf test.tar.gz -C dist/ #解壓項目到dist目錄
rm -rf test.tar.gz #刪除壓縮包
rm -rf /usr/local/nginx/html/你的項目文件名稱
mv /usr/local/nginx/html/dist /usr/local/nginx/html/你的項目文件名稱
echo "部署成功!"
到了這里,關于jenkins 自由風格部署vue項目,參數(shù)化構建vue項目的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!