Search code examples
jenkinsnpmshellexecutenpm-runnpm-build

npm run build fails "only when" executed using Jenkins execute shell


Below is the npm run build when ran using root user from the command prompt on a Ubuntu Linux host:

As you can see from the output despite suggestions the command ran successfully as evident from the output of echo $?

enter image description here

However, when I run the same command using Jenkins "execute shell" with root user it fails as seen in the below output:

cd /etc/jenkins_tmp/workspace/SGGS_QA_UI;
npm run build
    if [ $? -eq 0 ]; then
    echo "npm build was successful. Copying ...";
    else
    echo " npm install failed. Check Jenkins console out";
    fi

enter image description here

Output:

  Line 151:8:  React Hook useEffect has missing dependencies: 'callSetLoggedIn', 'navigate', and 'setCurrentPage'. Either include them or remove the dependency array  react-hooks/exhaustive-deps

src/pages/resetpassword/Resetpassword.jsx
  Line 1:29:  'useEffect' is defined but never used  no-unused-vars
  Line 14:8:  'ResendOtp' is defined but never used  no-unused-vars


Build step 'Execute shell' marked build as a failure
Finished: FAILURE

I have checked the resources, server health and disk space for Jenkins as well as the target server where the npm run build executes and everything looks fine.

Can you please suggest how can I identify and fix the issue so Jenkins can do a successful npm run build?


Solution

  • changed to CI=false npm run build to resolve the issue as else it was considering the warning messages as error messages.

    I still have no clue why it was not failing when running through the command line without Jenkins.