问题:
1.本地开发环境页面和Jenkins部署服务器157上的开发环境页面不一致
2.检查了Jenkins部署的代码是git上最新的
3.下午4点左右江涛再次配置了开发环境的资源,构建后,157上页面显示正常,5点半左右检查,157页面依旧有问题,配置的资源也失效了
4.猜测是Jenkins会同步生产环境资源配置到测试和开发 或者 Jenkins配置的问题
原因:
一、排查了Jenkins的配置:代码拉取地址、代码是否同步--都没问题
二、检查Jenkins构建日志,发现两块错误
1.所有项目构建时都会报的错误
npm ERR! path /root/jenkins/workspace/intern-mobile-dev-git-157/node_modules/tar
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall access
npm ERR! enoent ENOENT: no such file or directory, access '/root/jenkins/workspace/intern-mobile-dev-git-157/node_modules/tar'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /home/admin/.npm/_logs/2019-07-16T21_36_36_841Z-debug.log
2.只有本项目构建有的错误
> ng run app:build:beta
Date: 2019-07-16T21:39:36.038Z
Hash: d3d791821fe06fdc45ec
Time: 29724ms
chunk {0} runtime.a5dd35324ddfd942bef1.js (runtime) 1.41 kB [entry] [rendered]
chunk {1} main.5f13b498ec6976cdb0c7.js (main) 128 bytes [initial] [rendered]
chunk {2} polyfills.cc3ea7a3070884bdee7e.js (polyfills) 130 bytes [initial] [rendered]
chunk {3} styles.11812d4741fdf74faf07.css (styles) 20 kB [initial] [rendered]
ERROR in src/app/home-main/practice-notes/practice-notes.page.html(4,70): : Property 'download' does not exist on type 'PracticeNotesPage'.
src/app/home-main/practice-notes/checkpractice-notes/checkpractice-notes.page.html(3,69): : Property 'submitToBackEnd' does not exist on type 'CheckpracticeNotesPage'.
src/app/home-main/practice-notes/checkpractice-notes/checkpractice-notes.page.html(4,72): : Property 'submitToBackEnd' does not exist on type 'CheckpracticeNotesPage'.
src/app/me-main/daily-record/daily-record.page.html(23,105): : Property 'feeling' does not exist on type 'DailyRecordModel'. Did you mean 'felling'?
src/app/me-main/daily-record/daily-record.page.html(23,105): : Property 'feeling' does not exist on type 'DailyRecordModel'. Did you mean 'felling'?
[ERROR] An error occurred while running subprocess ng.
ng run app:build:beta exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
-- 完成ionic build --configuration=beta
三、本地与服务器部署不一致的原因:
1.在二、1.中的错误,经过兄弟项目的测试验证表示没问题(在此致谢金鹏大佬),二、2.中构建出错了,可是Jenkins最后给的结果是成功,导致我们不知道代码打包出错
2.相关工作记录如下
-- 完成ionic build --configuration=beta
SSH: Connecting from host [localhost.localdomain]
SSH: Connecting with configuration [192.168.22.157] ...
SSH: EXEC: STDOUT/STDERR from command [#!/bin/sh
ROOT_PATH=/usr/local/intern
path=$ROOT_PATH/intern-mobile-dev
back_path=$ROOT_PATH/back
dev_path=$ROOT_PATH/dev
echo -$ROOT_PATH
echo --开始拷贝
#cp -r /usr/java/latest/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin/. $back_path
#cp -r $dev_path/. $paht
echo --拷贝成功
] ...
-/usr/local/intern
--开始拷贝
--拷贝成功
SSH: EXEC: completed after 201 ms
SSH: Disconnecting configuration [192.168.22.157] ...
SSH: Transferred 0 file(s)
Finished: SUCCESS
解决:
1.在本地运行打包命令:
ng run app:build:beta
2.解决打包后的报错
3.将正确代码推到git,执行Jenkins构建
4.验证部署成功!
总结:
1.Jenkins所有项目构建都报的错误 和 是否有设置错误忽略的问题 已经交由Jenkins负责人解决
2.特别鸣谢:贺信、连迎迎、杜雨、程金鹏、杨江涛、李勇杰、张伟光(排名不分前后,特效应为LED放大标红滚动循环播出),谢谢各位的帮助与指教!