[英]Jenkins, rbenv, bundler - When using Jenkins and rbenv, how does the rbenv plugin preinstall bundler, and why isn't it in my case?
I'm setting up a CI environment on OSX using Jenkins and Appium's Ruby library. 我正在使用Jenkins和Appium的Ruby库在OSX上建立CI环境。
I'm using a rake task to launch my test suite in RSpec. 我正在使用rake任务在RSpec中启动我的测试套件。
Using a similar configuration, I was able to run the tests with Jenkins on another machine. 使用类似的配置,我能够在另一台机器上使用Jenkins运行测试。 I'm now using rbenv (and the rbenv plugin) and having some issues.
我现在正在使用rbenv(和rbenv插件)并遇到一些问题。
Here's what I get when I try to run the job: 这是我尝试运行工作时得到的结果:
$ bash -c "[ -d \$HOME/.rbenv-jenkins ]"
$ bash -c "[ -d \$HOME/.rbenv-jenkins/plugins/ruby-build ]"
$ bash -c "cd /Users/Shared/Jenkins/Home/workspace/Tests && env RBENV_ROOT\=\$HOME/.rbenv-jenkins RBENV_VERSION\=2.2.5 CONFIGURE_OPTS\= RUBY_CONFIGURE_OPTS\= \$HOME/.rbenv-jenkins/bin/rbenv local 2>/dev/null || true"
Use local Ruby version 2.2.5.
$ bash -c "mkdir \$HOME/.rbenv-jenkins/.lock"
$ bash -c "env RBENV_ROOT\=\$HOME/.rbenv-jenkins RBENV_VERSION\=2.2.5 CONFIGURE_OPTS\= RUBY_CONFIGURE_OPTS\= \$HOME/.rbenv-jenkins/bin/rbenv versions --bare"
$ bash -c "env RBENV_ROOT\=\$HOME/.rbenv-jenkins RBENV_VERSION\=2.2.5 CONFIGURE_OPTS\= RUBY_CONFIGURE_OPTS\= \$HOME/.rbenv-jenkins/bin/rbenv rehash"
$ bash -c "env RBENV_ROOT\=\$HOME/.rbenv-jenkins RBENV_VERSION\=2.2.5 CONFIGURE_OPTS\= RUBY_CONFIGURE_OPTS\= \$HOME/.rbenv-jenkins/bin/rbenv exec gem list"
$ bash -c "env RBENV_ROOT\=\$HOME/.rbenv-jenkins RBENV_VERSION\=2.2.5 CONFIGURE_OPTS\= RUBY_CONFIGURE_OPTS\= \$HOME/.rbenv-jenkins/bin/rbenv rehash"
$ bash -c "rm -rf \$HOME/.rbenv-jenkins/.lock"
[Tests] $ bundle exec rake ios
FATAL: rake execution failed
java.io.IOException: Cannot run program "bundle" (in directory "/Users/Shared/Jenkins/Home/workspace/Tests"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at hudson.Proc$LocalProc.<init>(Proc.java:240)
at hudson.Proc$LocalProc.<init>(Proc.java:212)
etc. 等等
It seems like there is an issue with bundler's exec not being where it is supposed to be. 似乎捆绑器的exec存在问题,而不是它应该在的位置。
I've tried adding export PATH="$HOME/.rbenv-jenkins/bin:$PATH"
to the path in a few ways, but it seems like it doesn't make a difference - when it's a shell step I see it run, but I get no change. 我尝试在几个方面将路径
export PATH="$HOME/.rbenv-jenkins/bin:$PATH"
到路径中,但似乎它没有什么区别 - 当它是一个shell步骤我看到它跑,但我没有变化。
I have preinstall rake and bundler enabled with my rbenv plugin, but I don't see them getting installed - I'm not sure why. 我已经预装了我的rbenv插件启用的rake和bundler,但是我没有看到它们被安装 - 我不知道为什么。
I am able to run tests via rspec
, rake
and bundle exec rake
when I'm logged in to the Jenkins user. 当我登录Jenkins用户时,我可以通过
rspec
, rake
和bundle exec rake
运行测试。
Any idea what's not doing what it's supposed to be? 知道什么不做它应该是什么? Let me know if there are any missing details, and thank you!
如果有任何遗漏的细节,请告诉我,谢谢!
edit: 编辑:
When I add gem install bundle
and gem install rake
shell commands, I get the following: 当我添加
gem install bundle
和gem install rake
shell命令时,我得到以下内容:
+ gem install bundler
Successfully installed bundler-1.13.2
Parsing documentation for bundler-1.13.2
Done installing documentation for bundler after 4 seconds
1 gem installed
+ gem install rake
ERROR: Error installing rake:
"rake" from rake conflicts with /Users/Shared/Jenkins/.rbenv-jenkins/versions/2.2.5/bin/rake
Build step 'Execute shell' marked build as failure
Finished: FAILURE
My pre-install gems are rake,bundler
- but it seems like only rake gets pre-installed correctly. 我的预安装宝石是
rake,bundler
- 但似乎只有rake才能正确预装。
Running the job without installing rake (and with an rbenv rehash following the bundler install), I get the same error. 在没有安装rake的情况下运行作业(并且在安装捆绑器后使用rbenv rehash),我得到了同样的错误。
In this case, it turned out to be an error with gem dependencies - a bad nokogiri installation when all was said and done. 在这种情况下,结果证明是一个错误的宝石依赖 - 一个糟糕的nokogiri安装,当所有的说完成。
I was able to reveal the error message that got me hunting by running bundle exec rake ios
(my test task) as a shell command rather than as a rake task via the plugin. 通过运行
bundle exec rake ios
(我的测试任务)作为shell命令而不是通过插件执行rake任务,我能够揭示错误信息让我狩猎。
From there, I got an error about a bad version and after trying some gemfile tweaks (and nuking my Gemfile.lock), I ran bundle install as a shell line and noticed the nokogiri installation failing in familiar ways (due to some Xcode version juggling that I suspect is fairly idiosyncratic). 从那里,我得到一个错误的错误版本和尝试一些gemfile调整(和我的Gemfile.lock)后,我运行bundle install作为shell行,并注意到nokogiri安装失败以熟悉的方式(由于一些Xcode版本杂耍我怀疑这是相当特殊的)。
So, if you're lost and looking for guidance in a similar spot, try running the task as a shell line so you get more verbose errors. 因此,如果您丢失并在类似的位置寻找指导,请尝试将任务作为shell行运行,以便您获得更详细的错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.