skip to Main Content

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


  1. Chosen as BEST ANSWER

    After look closer to the jenkins output, I found this

    Treating warnings as errors because process.env.CI = true.
    Most CI servers set it automatically.
    
    Failed to compile.
    

    It looks like Jenkins should handle CI variable but it does not.

    I add the following line to script and it works.

    CI=false
    

    If there are better way to handle this, please let me know.

    Thanks,


  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search