docker-compose.yml
version: '3'
services:
jenkins:
image: jenkinsci/blueocean
container_name: jenkins-blueocean
restart: unless-stopped
network_mode: host
ports:
- 8080:8080
- 50000:50000
volumes:
- /var/jenkins-data:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
一,新建一个自由风格的软件项目
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环境上面去了。
<pre class="console-output" >[前端-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
> [email protected] 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>
注:如果遇到前端项目打包非常慢可以尝试修改/root/.npmrc文件的配置
registry=https://registry.npmmirror.com/
sass_binary_site=https://npmmirror.com/mirrors/node-sass/
electron_mirror=https://npmmirror.com/mirrors/electron/
disturl=https://npmmirror.com/mirrors/node/
chromedriver_cdnurl=https://npmmirror.com/mirrors/chromedriver/
operadriver_cdnurl=https://npmmirror.com/mirrors/operadriver/
phantomjs_cdnurl=https://repo.huaweicloud.com/phantomjs/
fse_binary_host_mirror=https://npmmirror.com/mirrors/fsevents/
selenium_cdnurl=https://npmmirror.com/mirrors/selenium/
node_inspector_cdnurl=https://npmmirror.com/mirrors/node-inspector/
nvm_nodejs_org_mirror=https://npmmirror.com/mirrors/node/
nodejs_org_mirror=https://npmmirror.com/mirrors/node/
profiler_binary_host_mirror=https://npmmirror.com/mirrors/node-inspector/
puppeteer_download_host=https://npmmirror.com/mirrors
sqlite3_binary_site=https://npmmirror.com/mirrors/sqlite3/
python_mirror=https://npmmirror.com/mirrors/python/
作者:一梦三四年lyp
链接:https://www.jianshu.com/p/21c61052e404
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。 标签:dist,mirrors,配置,构建,https,KiB,jenkins,npmmirror,com From: https://www.cnblogs.com/gaoyanbing/p/17219111.html