前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Jenkins自动构建vue项目

Jenkins自动构建vue项目

作者头像
崔哥
发布2022-12-05 15:46:29
1.2K0
发布2022-12-05 15:46:29
举报
文章被收录于专栏:崔哥的专栏

Jenkins安装 请参考:https://cloud.tencent.com/developer/article/2186451

ssh连接gitee

代码语言:javascript
复制
#生成公钥,私钥
root@edfd04c7ec00:/# ssh-keygen -t rsa -C "jenkins"

公钥配到gitee:https://gitee.com/profile/sshkeys

私钥配到Jenkins:Dashboard -> 系统管理 -> 凭据 -> 系统 -> 全局凭据 (unrestricted)

如上配置完,在拉取项目(git@gitee.com:chudaozhe/enterprise-admin.git)时,可能报错

代码语言:javascript
复制
returned status code 128:
stdout: 
stderr: No ECDSA host key is known for gitee.com and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.

这时,配置一下Git Host Key Verification Configuration就可以了

构建vue项目

配置nodejs

Dashboard -> 系统管理 -> 插件管理 -> 可选插件

搜索“nodejs”,安装即可

接着,Dashboard -> 系统管理 -> 全局工具配置

配置https://mirrors.aliyun.com/nodejs-release/

接着,测试一下

成功了

如上,是成功了,但因为没有加到环境变量,所以直接执行node -v是不行的

代码语言:javascript
复制
[root@nfsFileSystem vagrant]# node -v
bash: node: command not found
[root@nfsFileSystem vagrant]# /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/nodejs19/bin/node -v
v19.2.0

clone并构建vue项目

配置shell脚本

代码语言:javascript
复制
npm install --registry=https://registry.npm.taobao.org
npm run build

构建成功,会多一个dist目录

日志

代码语言:javascript
复制
First time build. Skipping changelog.
Unpacking https://mirrors.aliyun.com/nodejs-release/v19.2.0/node-v19.2.0-linux-x64.tar.gz to /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/nodejs19 on Jenkins
[vue_admin] $ /bin/sh -xe /tmp/jenkins9582283174751732397.sh
+ npm install --registry=https://registry.npm.taobao.org
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
...
added 1019 packages in 50s
+ npm run build

> vue_admin@1.0.0 build
> node build/build.js

(node:5656) Warning: Accessing non-existent property 'cat' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:5656) Warning: Accessing non-existent property 'cd' of module exports inside circular dependency
...
Starting to optimize CSS...
Processing static/css/app.67d5653a5ceee5df23c290c1efb8acd9.css...
Processed static/css/app.67d5653a5ceee5df23c290c1efb8acd9.css, before: 176458, after: 173025, ratio: 98.05%
Hash: ab5f3662432c354b153a
Version: webpack 2.7.0
Time: 30863ms
                                                  Asset       Size  Chunks                    Chunk Names
                 static/fonts/element-icons.b02bdc1.ttf    13.2 kB          [emitted]         
               static/js/vendor.a11188574e8c22a95fd9.js    1.19 MB       0  [emitted]  [big]  vendor
                  static/js/app.842d7b541ae50b8e1e0d.js     159 kB       1  [emitted]         app
             static/js/manifest.2496bc72a04420c949f3.js    1.51 kB       2  [emitted]         manifest
    static/css/app.67d5653a5ceee5df23c290c1efb8acd9.css     173 kB       1  [emitted]         app
           static/js/vendor.a11188574e8c22a95fd9.js.map    8.27 MB       0  [emitted]         vendor
              static/js/app.842d7b541ae50b8e1e0d.js.map     806 kB       1  [emitted]         app
static/css/app.67d5653a5ceee5df23c290c1efb8acd9.css.map     226 kB       1  [emitted]         app
         static/js/manifest.2496bc72a04420c949f3.js.map    14.7 kB       2  [emitted]         manifest
                                             index.html  492 bytes          [emitted]         
                                          static/xx.png    2.63 kB          [emitted]         
                                static/simditor-html.js    3.47 kB          [emitted]         
                                static/beautify-html.js    66.8 kB          [emitted]         

  Build complete.

  Tip: built files are meant to be served over an HTTP server.
  Opening index.html over file:// won't work.

Finished: SUCCESS

参考

https://blog.csdn.net/qq_39905409/article/details/122449380

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • ssh连接gitee
  • 构建vue项目
    • 配置nodejs
      • clone并构建vue项目
      • 参考
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档