ruby 无法运行 Jenkins Build - 捆绑:“找不到命令”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10365792/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't run Jenkins Build - bundle: "command not found"
提问by Jonathan Warykowski
I am currently trying to run a jenkins build for some of my cucumber tasks. All of my gems have been installed by using the Bundler. The gems are stored in the vendor folder.
我目前正在尝试为我的一些黄瓜任务运行 jenkins 构建。我所有的 gems 都是使用 Bundler 安装的。宝石存储在供应商文件夹中。
However, when I try and run bundle install --deploymentin the execute shell build step, I get the following error:
但是,当我尝试bundle install --deployment在执行 shell 构建步骤中运行时,出现以下错误:
Started by user anonymous
Building in workspace /Users/Shared/Jenkins/Home/jobs/cukes/workspace
[workspace] $ /bin/sh -xe/var/folders/zz/zyxvpxvq6csfxvn_n0000004000001/T/hudson4461284045505361460.sh
+ bundle install --deployment
/var/folders/zz/zyxvpxvq6csfxvn_n0000004000001/T/hudson4461284045505361460.sh: line 2: bundle: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE
This is driving me crazy! It runs on my local machine with no problems. Why can't Jenkins see my gems?
这真让我抓狂!它在我的本地机器上运行没有问题。为什么詹金斯看不到我的宝石?
Any help would be great!
任何帮助都会很棒!
Cheers, Jon
干杯,乔恩
回答by sti
Depending on the way you installed Jenkins, it might be running as a separate user, typically as user jenkins. If you have installed bundleinto a nonstandard directory which isn't in the default PATH, like /usr/local/bin, you need to:
根据您安装 Jenkins 的方式,它可能以单独的用户身份运行,通常以 user 身份运行jenkins。如果您已安装bundle到不在默认 PATH 中的非标准目录,例如/usr/local/bin,则需要:
- Add
/usr/local/binto the PATH of the jenkins user (check ~jenkins/.bashrc) or - Configure PATH environment variable in Jenkins global configuration (or slave configuration if building on a slave) or
- Modify the build script to refer to
bundleusing a full path name.
- 添加
/usr/local/bin到 jenkins 用户的 PATH(检查 ~jenkins/.bashrc)或 - 在 Jenkins 全局配置中配置 PATH 环境变量(如果在从属设备上构建,则为从属配置)或
- 修改构建脚本以
bundle使用完整路径名进行引用。
回答by Reza Dehnavi
In my case, I added this line to the first of script:
就我而言,我将此行添加到脚本的第一行:
#!/bin/bash -l
回答by Dan Herman
If bundle is installed in /usr/local/bin/bundle(determine this with which bundle) you could just add a symbolic link to bundle in /usr/binlike so:
如果 bundle 安装在/usr/local/bin/bundle(用 确定which bundle),你可以/usr/bin像这样添加一个符号链接到 bundle 中:
ln -s /usr/local/bin/bundle /usr/bin/bundle
ln -s /usr/local/bin/bundle /usr/bin/bundle
回答by malenkiy_scot
First things to verify:
首先要验证的事情:
- Make sure
bundleis installed on the machine where Jenkins runs. - If it installed, make sure it's on the path for the user under which Jenkins runs
- 确保
bundle已安装在运行 Jenkins 的机器上。 - 如果已安装,请确保它位于运行 Jenkins 的用户的路径上
(To verify path/environment: insert shell build step that runs env)
(要验证路径/环境:插入运行的 shell 构建步骤env)
回答by Senseful
For me I had originally installed it via the war file as that's the way recommended on the Getting Started Guide. However, the user handbook makes it much more clear that there are probably better ways to install Jenkins.
对我来说,我最初是通过 war 文件安装它的,因为这是入门指南中推荐的方式。但是,用户手册更清楚地表明可能有更好的方法来安装 Jenkins。
I ended up uninstalling the WAR file of Jenkins on macOS by:
我最终通过以下方式在 macOS 上卸载了 Jenkins 的 WAR 文件:
- Deleting the .war file.
- Deleting the ~/.jenkins directory.
- 删除 .war 文件。
- 删除 ~/.jenkins 目录。
I then reinstalled via home-brew, and bundlestarted working.
然后我通过 home-brew 重新安装,并bundle开始工作。
回答by Maged Makled
You could see where is bundleis installed by running which bundleand run the bundlecommand from there
您可以bundle通过运行which bundle并bundle从那里运行命令来查看安装位置

