美文网首页
jenkins多环境构建配置

jenkins多环境构建配置

作者: 一梦三四年lyp | 来源:发表于2021-05-20 21:03 被阅读0次

一,新建一个自由风格的软件项目


image.png

二,选择参数化构建过程
ENV:代表着部署的环境
branch: 代表的要拉取的代码分支


image.png

三,源码管理
Repository URL:添加项目的路径
Credentials:连接gitlab的凭证
*/${branch}:根据第二步选择的参数来拉取对应分支的代码


image.png

四,构建环境
1,Name:全局配置的环境
2,Label:根据第二步选择的ENV参数来匹配对应的环境
3,Source files:要移动的文件
4,Remote directory:目标服务器(Name)的相对路径
5,Exec command :目标服务器上需要执行的命令或者脚本
6,点击Add Server 右下角的高级按钮会弹出下面的第二张图,填写Parameterized publishing选项
Parameterized publishing:配置成我们第二步我们设置的参数ENV,此时构建会根据ENV的值来找匹配到的服务器(即之前服务器上设置的Label的值) 非常关键!!!!!

参考:

cd /home/www/frontend/ChinaMadeWww
rm rf dist-bak
mv dist dist-bak
tar -xvf erp.tar.gz
rm -rf  erp.tar.gz
chown -R www:www dist
image.png image.png
image.png

五,构建
npm run build:$ENV :根据传入的ENV参数来打包对应环境下的项目

node -v

cnpm install

npm run build:$ENV


tar -czf  erp.tar.gz ./dist/
image.png

六,构建界面
此时ENV下选择beta,branch下选择beta 就会拉取beta分支的代码,并打包推送到beta环境上面去了。

image.png
<pre class="console-output" style="box-sizing: inherit; font-size: var(--font-size-monospace); white-space: pre-wrap; overflow-wrap: break-word; margin: 0px; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;">[前端-ERP-服务端] $ /bin/sh -xe /tmp/jenkins6935008287829088439.sh
+ node -v
v16.1.0
+ cnpm install
✔ Installed 62 packages
✔ Linked 0 latest versions
✔ Run 0 scripts
✔ All packages installed (used 37ms(network 35ms), speed 0B/s, json 0(0B), tarball 0B)
+ npm run build:beta

> china-made-www@0.0.1 build:beta
> vue-cli-service build --mode beta

-  Building for beta...
 WARNING  Compiled with 5 warnings10:30:30 AM

 warning  in ./src/views/shipment/overseas/components/children/CreateOverseasWarehouseShipments.vue?vue&type=script&lang=js&

"export 'editRejectShipmentPlan' was not found in '@/api/shipment'

 warning  in ./src/views/shipment/overseas/components/children/CreateOverseasWarehouseShipments.vue?vue&type=script&lang=js&

"export 'getUnAuditProductList' was not found in '@/api/shipment'

 warning  in ./src/views/shipment/overseas/components/children/CreateOverseasWarehouseShipments.vue?vue&type=script&lang=js&

"export 'setUnAuditShipmentPlan' was not found in '@/api/shipment'

 warning  

Conflict: Multiple assets emit different content to the same filename static/fonts/element-icons.woff

 warning  

Conflict: Multiple assets emit different content to the same filename static/fonts/element-icons.ttf

  File                                      Size             Gzipped

  dist/js/chunk-libs.1621506578711.js       11845.99 KiB     2600.39 KiB
  dist/js/app.1621506578711.js              8855.88 KiB      610.04 KiB
  dist/js/chunk-elementUI.1621506578711\.    1669.55 KiB      287.69 KiB
  js
  dist/pdfjs-2.5.207-dist/build/pdf.work    1253.82 KiB      244.17 KiB
  er.js
  dist/pdfjs-2.5.207-dist/build/pdf.js      360.05 KiB       72.64 KiB
  dist/pdfjs-2.5.207-dist/web/viewer.js     335.75 KiB       68.56 KiB
  dist/pdfjs-2.5.207-dist/web/debugger.j    18.53 KiB        4.91 KiB
  s
  dist/lib/wwLogin-1.0.0.js                 0.71 KiB         0.44 KiB
  dist/css/app.1621506578711.css            1843.64 KiB      157.54 KiB
  dist/css/chunk-libs.1621506578711.css     131.26 KiB       21.26 KiB
  dist/pdfjs-2.5.207-dist/web/viewer.css    55.04 KiB        9.08 KiB

  Images and other types of assets omitted.

 DONE  Build complete. The dist directory is ready to be deployed.
 INFO  Check out deployment instructions at [https://cli.vuejs.org/guide/deployment.html](https://cli.vuejs.org/guide/deployment.html)

+ tar -czf erp.tar.gz ./dist/
SSH: Publishing to [预发环境] - Label [beta] matches expression [beta]
SSH: Connecting from host [0c75eb5b3483]
SSH: Connecting with configuration [预发环境] ...
SSH: EXEC: completed after 401 ms
SSH: Disconnecting configuration [预发环境] ...
SSH: Transferred 1 file(s)
SSH: Skipping [正式环境] - Label [prod] does not match expression [beta]
Finished: SUCCESS</pre>

相关文章

网友评论

      本文标题:jenkins多环境构建配置

      本文链接:https://www.haomeiwen.com/subject/jaibjltx.html