“仅当”使用Jenkins execute shell执行时,npm运行构建失败

byqmnocz  于 2023-03-17  发布在  Jenkins
关注(0)|答案(1)|浏览(258)

以下是在Ubuntu Linux主机上使用root用户从命令提示符运行时的npm run build
从输出中可以看到,尽管有建议,但命令成功运行,这从echo $?的输出中可以看出

但是,当我以root用户身份使用Jenkins“execute shell”运行相同的命令时,它失败了,如以下输出所示:

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

输出:

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

我已经检查了Jenkins的资源、服务器健康状况和磁盘空间,以及执行npm run build的目标服务器,一切看起来都很好。
您能否建议我如何识别和修复此问题,以便Jenkins能够成功执行npm run build

5fjcxozz

5fjcxozz1#

变更为CI=false npm run build以解决该问题,因为它将警告消息视为错误消息。
我仍然不知道为什么它没有失败时,通过命令行运行没有Jenkins。

相关问题