简体   繁体   English

Jenkins 在 PATH 中找不到二进制文件,并且似乎不是从 Linux 继承的

[英]Jenkins can't find binary in PATH and doesn't appear to inherit from Linux

I've tried everything for this an it's exhausted my knowledge.我已经为此尝试了一切,但已经耗尽了我的知识。 I'm trying to get Jenkins to use the Path from Linux and it's not working it seems.我试图让 Jenkins 使用来自 Linux 的路径,但它似乎不起作用。

Running Jenkins on RHEL Linux and Jenkins runs using the 'jenkins' user:在 RHEL Linux 上运行 Jenkins,Jenkins 使用“jenkins”用户运行: 在此处输入图片说明

If I sudo su as the 'jenkins' user, I can see items like Blaze and Firefox on the Path:如果我 sudo su 作为“jenkins”用户,我可以在路径上看到 Blaze 和 Firefox 之类的项目: 在此处输入图片说明

(Both Jenkins and the server have been restarted multiple times since these have been on the path) (Jenkins 和服务器都已多次重新启动,因为它们已经在路径上)

If I firefox -V while in a jenkins user bash, it works fine.如果我在jenkins用户 bash 中使用firefox -V ,它工作正常。 In a Jenkins job that attempts to use the Firefox driver, it errors with the following:在尝试使用 Firefox 驱动程序的 Jenkins 作业中,它出现以下错误:

Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: LINUX

In the System Info, it has PATH=/sbin:/usr/sbin:/bin:/usr/bin在系统信息中,它有PATH=/sbin:/usr/sbin:/bin:/usr/bin

Running as SYSTEM
[EnvInject] - Loading node environment variables.

The settings for the nodes are default, which I understand means it should inherit from linux节点的设置是默认的,我理解这意味着它应该从 linux 继承在此处输入图片说明

I also made a job that runs the following:我还做了一个运行以下内容的工作:

whoami
echo $PATH
firefox -V

This returns:这将返回:

+ whoami
jenkins
+ echo /sbin:/usr/sbin:/bin:/usr/bin
/sbin:/usr/sbin:/bin:/usr/bin
+ firefox -V
/tmp/jenkins4835013049839580673.sh: line 4: firefox: command not found

No matter what I try, I can't seem to get Jenkins to use the 'correct' Path value.无论我尝试什么,我似乎都无法让 Jenkins 使用“正确”的 Path 值。 Is there something I'm missing, or is it as confusing as I am feeling?是不是我遗漏了什么,或者它是否像我感觉的一样令人困惑?

Additional Stuff:额外的东西:

  • Adding a symlink into /usr/bin also doesn't work for some reason.出于某种原因,将符号链接添加到 /usr/bin 也不起作用。
  • I can't add them as "Environment Variables" within the Jenkins config as it seems to break the pipeline jobs that don't need the additional binaries.我无法在 Jenkins 配置中将它们添加为“环境变量”,因为它似乎破坏了不需要额外二进制文件的管道作业。

Can anyone help?任何人都可以帮忙吗?

I had the same problem and could not execute my grails binary from jenkins, as it was added "programmatically" when i started my terminal, which did not apply to Jenkins.我遇到了同样的问题,无法从 jenkins 执行我的 grails 二进制文件,因为它是在我启动终端时“以编程方式”添加的,这不适用于 Jenkins。 My solution was simply to symlink the grails binary to /usr/local/bin which was available in $PATH from Jenkins.我的解决方案只是将 grails 二进制文件符号链接到/usr/local/bin ,它可以在 Jenkins 的$PATH

Symlink using: sudo ln -s /home/jenkins/.sdkman/candidates/grails/5.0.1/bin/grails /usr/local/bin符号链接使用: sudo ln -s /home/jenkins/.sdkman/candidates/grails/5.0.1/bin/grails /usr/local/bin

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM