eirslett / frontend-maven-plugin

"Maven-node-grunt-gulp-npm-node-plugin to end all maven-node-grunt-gulp-npm-plugins." A Maven plugin that downloads/installs Node and NPM locally, runs NPM install, Grunt, Gulp and/or Karma.
Apache License 2.0
4.22k stars 868 forks source link

npm run build fails in jenkins pipeline , however works in local STS #980

Closed gopivemula1 closed 3 years ago

gopivemula1 commented 3 years ago

frontend-maven-plugin version: 1.12.0

Current Behaviour: when using this plugin to compile it is successful in local, however it fails jenkins pipeline.

pom.xml configuration

com.github.eirslett frontend-maven-plugin 1.12.0 config-react target install node and npm install-node-and-npm v13.10.0 npm clean npm cache clean --force npm install npm install npm run build npm run build maven-antrun-plugin generate-resources run

Log file:

 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/var/lib/jenkins/workspace/config-pipeline/target/node/node',
1 verbose cli   '/var/lib/jenkins/workspace/config-pipeline/target/node/node_modules/npm/bin/npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'build'
1 verbose cli ]
2 info using npm@6.13.7
3 info using node@v13.10.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle config-react@0.1.0~prebuild: config-react@0.1.0
6 info lifecycle config-react@0.1.0~build: config-react@0.1.0
7 verbose lifecycle config-react@0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle config-react@0.1.0~build: PATH: /var/lib/jenkins/workspace/config-pipeline/target/node/node_modules/npm/node_modules/npm-lifecycl
e/node-gyp-bin:/var/lib/jenkins/workspace/config-pipeline/config-react/node_modules/.bin:/var/lib/jenkins/workspace/config-pipeline/target/node:/opt/
softwares/apache-maven-3.8.1/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:
9 verbose lifecycle config-react@0.1.0~build: CWD: /var/lib/jenkins/workspace/config-pipeline/config-react
10 silly lifecycle config-react@0.1.0~build: Args: [ '-c', 'react-scripts build' ]
11 silly lifecycle config-react@0.1.0~build: Returned: code: 1  signal: null
12 info lifecycle config-react@0.1.0~build: Failed to exec build script
13 verbose stack Error: config-react@0.1.0 build: `react-scripts build`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/var/lib/jenkins/workspace/config-pipeline/target/node/node_modules/npm/node_modules/npm-lifecycle/
index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:321:20)
13 verbose stack     at ChildProcess.<anonymous> (/var/lib/jenkins/workspace/config-pipeline/target/node/node_modules/npm/node_modules/npm-lifecycle/
lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:321:20)
13 verbose stack     at maybeClose (internal/child_process.js:1026:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid config-react@0.1.0
15 verbose cwd /var/lib/jenkins/workspace/config-pipeline/config-react
16 verbose Linux 4.18.0-305.3.1.el8.x86_64
17 verbose argv "/var/lib/jenkins/workspace/config-pipeline/target/node/node" "/var/lib/jenkins/workspace/config-pipeline/target/node/node_modules/np
m/bin/npm-cli.js" "run" "build"
18 verbose node v13.10.0
19 verbose npm  v6.13.7
20 error code ELIFECYCLE
21 error errno 1
22 error config-react@0.1.0 build: `react-scripts build`
22 error Exit status 1
23 error Failed at the config-react@0.1.0 build script.

Jenkins Logs:

[INFO] --- frontend-maven-plugin:1.12.0:install-node-and-npm (install node and npm) @ liverpool-configuration ---
[INFO] Installing node version v13.10.0
[INFO] Unpacking /var/lib/jenkins/.m2/repository/com/github/eirslett/node/13.10.0/node-13.10.0-linux-x64.tar.gz into /var/lib/jenkins/workspace/config-pipeline/target/node/tmp
[INFO] Copying node binary from /var/lib/jenkins/workspace/config-pipeline/target/node/tmp/node-v13.10.0-linux-x64/bin/node to /var/lib/jenkins/workspace/config-pipeline/target/node/node
[INFO] Extracting NPM
[INFO] Installed node locally.
[INFO] 
[INFO] --- frontend-maven-plugin:1.12.0:npm (npm clean) @ liverpool-configuration ---
[INFO] Running 'npm cache clean --force' in /var/lib/jenkins/workspace/config-pipeline/config-react
[INFO] npm WARN using --force I sure hope you know what you are doing.
[INFO] 
[INFO] --- frontend-maven-plugin:1.12.0:npm (npm install) @ liverpool-configuration ---
[INFO] Running 'npm install' in /var/lib/jenkins/workspace/config-pipeline/config-react
[INFO] npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
[INFO] npm WARN deprecated babel-eslint@10.1.0: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
[INFO] npm WARN deprecated har-validator@5.1.5: this library is no longer supported
[INFO] npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
[INFO] npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
[INFO] npm WARN deprecated querystring@0.2.1: The
[INFO] npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
[INFO] npm WARN deprecated querystring@0.2.0: The
[INFO] npm WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi'
[INFO] npm WARN deprecated rollup-plugin-babel@4.4.0: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-babel.
[INFO] npm WARN deprecated sane@4.1.0: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added
[INFO] npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
[INFO] npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address'
[INFO] npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
[INFO] npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
[INFO] npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
[INFO] npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
[INFO] 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. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
[INFO] 
[INFO] > core-js@2.6.12 postinstall /var/lib/jenkins/workspace/config-pipeline/config-react/node_modules/babel-runtime/node_modules/core-js
[INFO] > node -e "try{require('./postinstall')}catch(e){}"
[INFO] 
[INFO] 
[INFO] > core-js@3.15.2 postinstall /var/lib/jenkins/workspace/config-pipeline/config-react/node_modules/core-js
[INFO] > node -e "try{require('./postinstall')}catch(e){}"
[INFO] 
[INFO] 
[INFO] > core-js-pure@3.15.2 postinstall /var/lib/jenkins/workspace/config-pipeline/config-react/node_modules/core-js-pure
[INFO] > node -e "try{require('./postinstall')}catch(e){}"
[INFO] 
[INFO] 
[INFO] > ejs@2.7.4 postinstall /var/lib/jenkins/workspace/config-pipeline/config-react/node_modules/ejs
[INFO] > node ./postinstall.js
[INFO] 
[INFO] npm notice created a lockfile as package-lock.json. You should commit this file.
[INFO] npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^2.1.3 (node_modules/react-scripts/node_modules/fsevents):
[INFO] npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
[INFO] npm WARN notsup Unsupported engine for eslint-utils@3.0.0: wanted: {"node":"^10.0.0 || ^12.0.0 || >= 14.0.0"} (current: {"node":"13.10.0","npm":"6.13.7"})
[INFO] npm WARN notsup Not compatible with your version of node/npm: eslint-utils@3.0.0
[INFO] npm WARN notsup Unsupported engine for postcss@8.3.5: wanted: {"node":"^10 || ^12 || >=14"} (current: {"node":"13.10.0","npm":"6.13.7"})
[INFO] npm WARN notsup Not compatible with your version of node/npm: postcss@8.3.5
[INFO] npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/watchpack-chokidar2/node_modules/chokidar/node_modules/fsevents):
[INFO] npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
[INFO] npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/webpack-dev-server/node_modules/chokidar/node_modules/fsevents):
[INFO] npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
[INFO] npm WARN @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@7.14.5 requires a peer of @babel/core@^7.13.0 but none is installed. You must install peer dependencies yourself.
[INFO] npm WARN tsutils@3.21.0 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
[INFO] 
[INFO] added 1920 packages from 841 contributors and audited 1924 packages in 52.015s
[INFO] 
[INFO] 143 packages are looking for funding
[INFO]   run `npm fund` for details
[INFO] 
[INFO] found 5 vulnerabilities (3 moderate, 2 high)
[INFO]   run `npm audit fix` to fix them, or `npm audit` for details
[INFO] 
[INFO] --- frontend-maven-plugin:1.12.0:npm (npm run build) @ liverpool-configuration ---
[INFO] Running 'npm run build' in /var/lib/jenkins/workspace/config-pipeline/config-react
[INFO] 
[INFO] > config-react@0.1.0 build /var/lib/jenkins/workspace/config-pipeline/config-react
[INFO] > react-scripts build
[INFO] 
[INFO] Creating an optimized production build...
[INFO] 
[INFO] Treating warnings as errors because process.env.CI = true.
[INFO] Most CI servers set it automatically.
[INFO] 
[INFO] Failed to compile.
[INFO] npm ERR! code ELIFECYCLE
[INFO] npm ERR! errno 1
[INFO] npm ERR! config-react@0.1.0 build: `react-scripts build`
[INFO] npm ERR! Exit status 1
[INFO] npm ERR! 
[INFO] npm ERR! Failed at the config-react@0.1.0 build script.
[INFO] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[INFO] 
[INFO] npm ERR! A complete log of this run can be found in:
[INFO] npm ERR!     /var/lib/jenkins/.npm/_logs/2021-07-06T11_58_11_996Z-debug.log
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
eirslett commented 3 years ago

Looks like react-scripts build is failing. Maybe it has a verbose mode, so you can get more debug output?

gopivemula1 commented 3 years ago

Looks like react-scripts build is failing. Maybe it has a verbose mode, so you can get more debug output?

Hi @eirslett it runs with out errors in Mac, windows . Fails only in Jenkins.

eirslett commented 3 years ago

I'm sorry, with this little information I am not able to help. Maybe it's a Linux issue.

mkpasala commented 3 years ago

@eirslett you can not simple say Linux issue and close it, you can help how to resolve this issue. I am facing the same issue after pushing my project code and try to build through jenkins. I spent 4 weeks of my time on POC based on this plugin, now what should I do if its failing to deploy in QA environment.

eirslett commented 3 years ago

@eirslett you can not simple say Linux issue and close it, you can help how to resolve this issue.

I closed the issue because (to me) it looks like it's a react-scripts bug, and not a bug with this plugin.

It's an open source project that you can use for free, I made it voluntarily in my free time. I have no obligations to help anybody. But if you pay me an hourly rate and give me access to the Jenkins server, I can try to help you debug!

The output says Treating warnings as errors because process.env.CI = true. You could try running CI=true npm run build locally/on Mac and see if that reproduces the problem locally.

gopivemula1 commented 3 years ago

@eirslett you can not simple say Linux issue and close it, you can help how to resolve this issue. I am facing the same issue after pushing my project code and try to build through jenkins. I spent 4 weeks of my time on POC based on this plugin, now what should I do if its failing to deploy in QA environment.

@mkpasala this plugin is not working for Jenkins. I used docker and docker-compose to build and deploy my react and springboot as alternate solution.

TechieEny commented 2 years ago

[Pipeline] Start of Pipeline [Pipeline] node Running on Jenkins in /var/lib/jenkins/workspace/Testnet-pipeline [Pipeline] { [Pipeline] tool [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline ERROR: No tool named maven3.8.4 found Finished: FAILURE

TechieEny commented 2 years ago

What do I do?

eirslett commented 2 years ago

What do I do?

I don't think this is a problem with the frontend-maven-plugin. Looks like you're trying to use Maven 3.8.4 (configured in your build somewhere) but you haven't installed it on your Jenkins properly?

sagar-wirtual commented 1 year ago

okay so i had been facing the same issue with a react-based application build that i was running on jenkins

[INFO] Treating warnings as errors because process.env.CI = true. [INFO] Most CI servers set it automatically.

here in your .env file you have to change process.env.CI = false if you want your project to compile in jenkins with warnings successfully. or else jenkins will always fail the build/pipeline

ref - https://stackoverflow.com/questions/52888214/how-to-set-environment-variable-in-react-js

pf-manish-thakur commented 1 year ago

Hey, I am facing an issue with Jenkins 0:0 error Parsing error: No Babel config file detected for /home/jenkins/agent/workspace/.../.Either disable config file checking with requireConfigFile: false, or configure Babel so that it can find the config files Also things are working fine with my localhost I already tried multiple options but nothing works for me Can anyone help me out with this issue