I am tring to run script to build react app and copy it to deploy folder in jenkins but failed.
shell in jenking like this:
npm cache clean --force
npm install
npm run build
rm -rf $DEPLOY_PATH/*
cp -r $WORKSPACE/build/* $DEPLOY_PATH
After job complete, jenkins give me this:
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] build: `react-scripts build` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I don’t understand, the script tested in windows 11 and debian 10.9 and jenkins running on debian 10.9. Why only jenkins got build error?
2
Answers
After look closer to the jenkins output, I found this
It looks like Jenkins should handle CI variable but it does not.
I add the following line to script and it works.
If there are better way to handle this, please let me know.
Thanks,
pay attention that you did all of below step:
1.your package.json test should be this:
"react-scripts build",
2.you should be in true directory if you are not move to directory by cd in terminal,
if you still get error try to update your npm and try again.