gpt4 book ai didi

node.js - 在 Jenkins docker 实例上找不到 Node

转载 作者:太空宇宙 更新时间:2023-11-04 01:57:18 25 4
gpt4 key购买 nike

我正在将 Jenkins 作为 docker 容器运行,并安装了 NodeJS plugin并彻底遵循安装说明。当我尝试使用 node 运行脚本时,出现以下错误:

/tmp/jenkins9123978873441132802.sh: line 1: node: not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE

我检查了 docker 卷,node bin 位于它应该在的位置并且可执行文件在那里,当我从主机服务器运行它时它工作正常:

user@server:/data/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/latest/bin$ ./node --version
v9.2.0

我修改了构建脚本以进一步探讨问题:

echo $PATH

cd /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/latest/bin
ls -all
./node --version

node --version
npm --version

看看这有多么奇怪:

Building in workspace /var/jenkins_home/workspace/release
[WS-CLEANUP] Deleting project workspace...
[WS-CLEANUP] Done
Adding all registry entries
copy managed file [Main config] to file:/var/jenkins_home/workspace/release@tmp/config69012336710357692tmp
[release] $ /bin/sh -xe /tmp/jenkins6243047436861395796.sh
+ echo /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/latest/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin
/var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/latest/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin
+ cd /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/latest/bin
+ ls -all
total 34112
drwxr-xr-x 2 jenkins jenkins 4096 Nov 20 16:16 .
drwxr-xr-x 6 jenkins jenkins 4096 Nov 20 16:16 ..
-rwxrwxrwx 1 jenkins jenkins 34921762 Nov 14 20:33 node
lrwxrwxrwx 1 jenkins jenkins 38 Nov 20 16:16 npm -> ../lib/node_modules/npm/bin/npm-cli.js
lrwxrwxrwx 1 jenkins jenkins 38 Nov 20 16:16 npx -> ../lib/node_modules/npm/bin/npx-cli.js
+ ./node --version
/tmp/jenkins6243047436861395796.sh: line 1: ./node: not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE

node 可执行文件存在,并且它是可执行的 (+x)。路径设置正确,但构建仍然失败。

最佳答案

这是因为 Node 二进制文件的路径

/data/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/latest/bin

您的 shell 路径中不存在。

你应该edit Jenkins' variables调整你的路径。

关于node.js - 在 Jenkins docker 实例上找不到 Node ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47401869/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com