zoukankan      html  css  js  c++  java
  • 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/
     

  • 相关阅读:
    MacBook设置终端颜色,补全忽略大小写,设置命令别名alias,设置vim,设置显示git分支
    lvs
    java lock锁住特定对象
    java实现版本比较
    mysql根据时间查询日期的优化
    DIV固定宽度和动态拉伸混合水平排列
    js控制input text字符键入/字符长度限制/字母自动大写
    CSS实现响应式布局(自动拆分几列)
    重命名流程
    div按照屏幕尺寸(设备大小)进行缩放
  • 原文地址:https://www.cnblogs.com/cheyunhua/p/14189829.html
Copyright © 2011-2022 走看看