stage('Install') { steps { dir("${serviceName}") { sh ''' source /opt/rh/devtoolset-7/enable npm config set python /usr/local/python3/bin/python3 npm config set registry https://registry.npm.taobao.org npm install ''' } } }
stage('Build') { steps { dir("${serviceName}") { sh """ npm run build:test """ } } } stage('Build ansible-playbook') { steps { script { sh """ rm -rf roles/${serviceName} # 清理release mv roles/projectname roles/${serviceName} cd ${serviceName}/dist/ zip -9rv ${WORKSPACE}/roles/${serviceName}/files/${serviceName}.zip * cd ${WORKSPACE} sed -i 's/groupname/${serviceName}/' hosts sed -i 's/\\(projectname: \\).*/\\1${serviceName}/g' site.yml sed -i 's/\\(programfile: \\).*/\\1${serviceName}.zip/g' site.yml """ } } }
stage('Deploy To Remote Host') { steps { script { sh "ansible-playbook -i hosts site.yml" } } } } }
2. 解决canvas依赖问题
Jenkins控制面板上一跑才发现,错误一大堆!!!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
+ npm config set python /usr/1ocal/python3/bin/python3 + npm --registry=https://registry. npm. taobao. org install npm WARN deprecated 9hapi/topo03. 1.6: This version has been deprecated and is no longer supported or maintained ..... npm WARN deprecated core-js02.6.12: core-js0<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could Ci to the actual version of core-js. npm ERR! code 1 npm BRR! path /var/1ib/ jenkins/ jobs/tfxing-official-dev/workspace/ode_modu1es/canvas apm ERR! command failed # 关键错误信息 ipm ERR! command sh -c node-pre-gyp install -- fallback-to-build npm BRR! Failed to execute '/var/1ib/ jenkins/tools/ jenkins. plugins. nodejs. tools. NodeJSInstallation/nodejs/bin/node /var/1ib/ jenkins/tools/ jenkins. plugins. nodejs. tools. NodeJSInstallation/nodejs/1ib/node. modules/npm module=/var/lib/ jenkins/ jobs/tfxing-official-dev/workspace/node_ _modules/canvas/bui1d/Release/canvas. node --module_name=canvas --module_ path=/var/1ib/ jenkins/ jobs/tfxing-official-dev/workspace/node_modules/canvas/bl node_ napi 1abel=node-v93 --python=/usr/1ocal/python3/bin/python3’ (1) npm ERR! node-pre-gyp info it worked if it ends with ok .....
+ npm config set python /usr/1ocal/python3/bin/python3 npm config set registry https://registry. npm. taobao. org + npm install canvas02.9.0 # 单独安装canvas npm WARN deprecated @hapi/topo03.1.6: This version has been deprecated and is no longer supported or maintained npm WARN deprecated Chapi/bourne01.3.2: This version has been deprecated and is no longer supported or maintained npm WARN deprecated urix0.1.0: Please see https://github. com/1yde11/urix#deprecated npm WARN deprecated har-validator05.1.5: this library is no 1onger supported npm WARN deprecated eslint-loader02.2. 1: This loader has been deprecated. Please use eslint-webpack-plugin npm WARN deprecated resolve-ur100.2. 1: https://github. com/lyde1l/resolve-ur1#deprecated npm WARN deprecated chokidar02.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies. npm WARN deprecated chokidar02. 1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies. npm WARN deprecated querystring0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead. npm WARN deprecated html-webpack-plugin03.2.0: 3.x is no longer supported npm WARN deprecated babel-eslint010.1.0: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates. npm WARN deprecated Qhapi/address02. 1.4: Moved to。 npm install esideway/address ' npm WARN deprecated uuid03.4.0: Please upgrade to version 7 or higher. 01der versions may use Math. random() in certain circumstances, which is known to be problematic. See https://v8. dev/b1og/math-random : npm WARN deprecated request02. 88.2: request has been deprecated, see https://github. com/request/request/issues/3142 npm WARN deprecated Qhapi/hoek08.5.1: This version has been deprecated and is no 1onger supported or maintained npm WARN deprecated Qhapi/joi015.1.1: Switch to 'npm install joi' npm WARN deprecated svg01.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x. npm WARN deprecated core-js02. 6.12: core-js0<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims,feature detection in old core-js versions could to the actual version of core-js. npm BRR! code 1 npm BRR! path /var/1ib/ jenkins/jobs/tfxing-official-dev/workspace/node_modules/node-sass # 此时又报依赖node-sass模块错误 npm ERR! command failed npm ERR! command sh -c node scripts/build. js
3. 解决node-sass依赖
没办法继续对node-sass模块进行独立安装,但仍旧报错:
1 2 3 4 5 6 7 8 9 10 11
+ npm install --python=/usr/bin/python ,node-sass0^4.0.0' npm WARN deprecated Chapi/topo@3. 1.6: This version has been deprecated and is no longer supported or maintained npm WARN deprecated Chapi/bourne01. 3.2: This version has been deprecated and is no longer supported or maintained .... npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', ' -C*,’huild' 1 npm ERR! g++: error: unrecognized command line option( ‘-std=gnu++14’ # 此处是关键错误信息 npm ERR! make: *** [Release/obj. target/libsass/src/libsass/src/ast.o] Error 1 npm ERR! gyp ERR! build error npm ERR! gyp ERR! stack Error: make failed with exit code: 2 ....
... npm ERR! gyp ERR! find Python checking Python explicitly set from command line or npm configuration npm ERR! gyp ERR! find Python -”- - python=”or' 'npm config get python” is" /usr/bin/python' npm ERR! 8yp ERR! find Python - executable path is" /usr/bin/python npm ERR! gyp ERR! find Python - version is "2. 7.5" npm ERR! gyp ERR! find Python - version is 2.7.5 - should be >=3.6.0. npm ERR! gyp ERR! find Python - THIS VBRSION OF PYTHON IS NOT SUPPORTED npm ERR! gyp ERR! find Python Python is not set from environment variable PYTHON npm ERR! gyp ERR! find Python checking if"python3” can be used npm ERR! gyp ERR! find Python -" python3” is not in PATH or produced an error npm ERR! gyp ERR! find Python checking if" python" can be used npm ERR! gyp ERR! find Python - executable path is" /bin/python' npm ERR! gyp ERR! find Python - version is "2. 7.5” npm ERR! 8yp ERR! find Python - version is 2. 7.5 - should be >=3. 6.0 npm ERR! gyp ERR! find Python - THIS VERSION 0F PYTHON IS NOT SUPPORTED npm ERR! gyp ERR! find Python npm ERR! gyp ERR! find Python ********************************************** npm ERR! gyp ERR! find Python You need to install the latest version of Python. npm BRR! 8Yp ERR! find Python Node-gyp should be able to find and use Python. If not, npm ERR! gyp ERR! find Python you can try one of the following options: npm ERR! gyp ERR! find Python - Use the switch --python=" /path/to/pythonexecutable" npm ERR! gyp ERR! find Python (accepted by both node-gyp and npm) npm ERR! gyp ERR! find Python - Set the environment variable PYTHON npm ERR! 8yP ERR! find Python - Set the npm configuration variable python: npm ERR! gyp ERR! find Python npm config set python "/path/to/pythonexecutable" npm ERR! gyp ERR! find Python For more information consult the documentation at: npm ERR! gyp ERR! find Python https://github. com/nodejs/node-gyp#installation npm ERR! gyp ERR! find Python ******************************************* nom ERR1 gvp ERR1 find Pvthon ...
npm ER! Package pixman-1 was not found in the pkg-config search path. npm ER! Perhaps you should add the directory containing pixman- 1.pc' npm ERR! to the PKG_CONFIG_ PATH envir onment variable npm ERR! No package'pixman-1’ found # 此为何方妖物呀!!!:( :( npm ERR! gyP: Call to’ pkg-config pixman-1 --libs’ returned exit status 1 whilein binding. gyp. while trying to load binding. gyPp npm ERR! gyP ERR! configure error npm ERR! gyP ERR! stack Error:、 gyP failed with exit code: 1
gcc version 7.3. 120180303 (Red Hat 7.3. 1-5) (GCC) + npm config set python /usr/1ocal/ python3/bin/ python3 + npm config set registry https:/fregistry. npm. taobao. org + npm install npm WARN deprecated @hapi/topo@3. 1. 6: This version has been deprecated and is no longer supported or maintained npm WARN deprecated @hapi/bourne@1.3. 2: This version has been deprecated and is no longer supported or maintained npm WARN deprecated urix@0. 1.0: Please see https: 1{ github. com/ 1ydell/ur ix#deprecated npm WARN deprecated har- -validator@5. 1.5: this library is no longer supported npm WARN deprecated eslint- loader@2.2. 1: This loader has been deprecated. Please use eslint- -webpack- plugin npm WARN deprecated resolve- url@0. 2.1: https: 11 github. com/ 1yde11/ resolve- -url#deprecated npm WARN deprecated chokidar@2. 1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies. npm WARN deprecated chokidar@2. 1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies. npm WARN deprecated querystring@0. 2.0: The querystring API is considered Legacy. new code should use the URL SearchParams API instead. npm WARN deprecated html-webpack- -plugin@3. 2.0: 3.x is no longer supported npm WARN deprecated babel-eslint@10. 1.0: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates. npm WARN deprecated @hapi/ address@2. 1.4: Moved to’npm install @sideway/ address' npm WARN deprecated uuid@3. 4. 0: Please upgrade to version 7 or higher. 01der versions may use Math. random() in certain circumstances npm WARN deprecated request@2. 88. 2: request has been deprecated, see https: //github. com/ request/ request/issues/3142 npm WARN deprecated @hapi/hoek@8.5. 1: This version has been deprecated and is no longer supported or maint ained npm WARN deprecated @hapi/joi@15. 1. 1: Switch to’npm install joi' npm WARN deprecated svgo@1. 3.2: This SVGO version is no longer supported. Upgrade to v2. x. x. npm WARN deprecated core- js@2. 6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Be to the actual version of core- js. added 1475 packages in 4m 87 packages are looking for funding run、npm fund~ for details