Jenkins自動化構建前端vue項目(nodejs環境)


轉載於https://dbawsp.com/1075.html

Nodejs官網

Nodejs中文網

安裝nodejs:
  • 在jenkins服務器安裝
[root@jenkinsserver ~]# mkdir /home/tools && cd /home/tools [root@jenkinsserver tools]# wget https://npm.taobao.org/mirrors/node/v12.10.0/node-v12.10.0-linux-x64.tar.gz [root@jenkinsserver tools]# tar -xf node-v12.10.0-linux-x64.tar.gz -C /usr/local [root@jenkinsserver tools]# ln -s /usr/local/node-v12.10.0-linux-x64 /usr/local/node [root@jenkinsserver tools]# echo 'export PATH=/usr/local/node/bin:$PATH' >> /etc/profile [root@jenkinsserver tools]# source /etc/profile [root@jenkinsserver tools]# node -v v12.10.0
 

優化nodejs:
# 使用國內源會下載的更快一點 [root@jenkinsserver tools]# npm config set registry https://registry.npm.taobao.org # 檢查是否正常 [root@jenkinsserver tools]# npm config get registry https://registry.npm.taobao.org/
 
升級nodejs版本:
[root@jenkinsserver tools]# npm install n -g # /usr/local/node-v12.10.0-linux-x64/bin/n -> /usr/local/node-v12.10.0-linux-x64/lib/node_modules/n/bin/n # + n@6.3.0 # added 1 package from 4 contributors in 0.524s [root@jenkinsserver tools]# n stable # # installing : node-v12.16.1 # mkdir : /usr/local/n/versions/node/12.16.1 # fetch : https://nodejs.org/dist/v12.16.1/node-v12.16.1-linux-x64.tar.xz # installed : v12.16.1 to /usr/local/bin/node # active : v12.10.0 at /usr/local/node/bin/node
 
手動構建node環境:
[root@jenkinsserver gitdata]# git clone -b test git@172.18.1.63:charges/charge-ui.git # Cloning into 'charge-ui'... # remote: Counting objects: 1790, done. # remote: Compressing objects: 100% (111/111), done. # remote: Total 1790 (delta 70), reused 103 (delta 40) # Receiving objects: 100% (1790/1790), 6.01 MiB | 0 bytes/s, done. # Resolving deltas: 100% (778/778), done [root@jenkinsserver gitdata]# cd charge-ui/ # 安裝node [root@jenkinsserver charge-ui]# npm install # ......省略一大堆輸出 # 打包vue項目 [root@jenkinsserver charge-ui]# npm run build
 

自動化構建node環境:

[root@jenkinsserver ~]# echo $PATH /usr/local/node/bin:/usr/local/maven/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
 

npm install rm -rf ./dist/* npm run build ls -lsh ./dist/
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM