请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

shell中使用了全路径还是build不成功

直接使用cnpm报错,然后我通过ln -s在/usr/bin下创建了cnpm的软连接
图片描述
jenkins中,shell如下

echo "运行cnpm install"
/usr/bin/cnpm install
echo "运行cnpm run build"
/usr/bin/cnpm run build
echo "构建成功"

报错如下

Started by user Andy
Running as SYSTEM
Building in workspace /var/lib/jenkins/workspace/online-store
The recommended git tool is: NONE
using credential gitee-user-password
 > git rev-parse --resolve-git-dir /var/lib/jenkins/workspace/online-store/.git # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://gitee.com/caoxuexi/online-store.git # timeout=10
Fetching upstream changes from https://gitee.com/caoxuexi/online-store.git
 > git --version # timeout=10
 > git --version # 'git version 1.8.3.1'
using GIT_ASKPASS to set credentials gitee的用户名和密码
 > git fetch --tags --progress https://gitee.com/caoxuexi/online-store.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
Checking out Revision 0b281cdf38265b401ed788293cfce30106cbac01 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 0b281cdf38265b401ed788293cfce30106cbac01 # timeout=10
Commit message: "删除文件 dist"
 > git rev-list --no-walk 0b281cdf38265b401ed788293cfce30106cbac01 # timeout=10
[online-store] $ /bin/sh -xe /tmp/jenkins5215932029698845276.sh
+ echo '运行cnpm install'
运行cnpm install
+ /usr/bin/cnpm install
/usr/bin/env: node: 没有那个文件或目录
Build step 'Execute shell' marked build as failure
Finished: FAILURE

顺带一提我用cnpm的原路径也是同样的错误

echo "运行cnpm install"
/root/tools/node-v14.17.0/bin/cnpm install
echo "运行cnpm run build"
/root/tools/node-v14.17.0/bin/cnpm run build
echo "构建成功"`

正在回答 回答被采纳积分+3

1回答

提问者 曹学习 2021-06-15 08:49:07

找到了,这里必须把NODE_HOME/bin下的node用软连接的方式在/usr/bin下创建一个软连接文件也叫node。虽然我已经在环境变量里配置了node,但是不知道为什么jenkins这里识别不到,必须要在/usr/bin下才能识别

1 回复 有任何疑惑可以回复我~
  • bobby #1
    是的,需要这样配置才行,jenkins这里确实识别不到
    回复 有任何疑惑可以回复我~ 2021-06-15 16:32:33
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信