在Ruby on Rails环境中设置Jenkins

问题描述:

我想安装Jenkins来构建然后部署我的rails应用程序,但是我的构建保持失败。这是因为詹金斯正在查看错误版本的Ruby,而不是使用RVM。下面是构建失败日志:在Ruby on Rails环境中设置Jenkins

/tmp/hudson3481773306458146820.sh: line 4: rvm: command not found 
/tmp/hudson3481773306458146820.sh: line 5: rvm: command not found 
/tmp/hudson3481773306458146820.sh: /usr/local/bin/bundle: /usr/bin/ruby1.9.1: bad interpreter: No such file or directory 
/tmp/hudson3481773306458146820.sh: /usr/local/bin/bundle: /usr/bin/ruby1.9.1: bad interpreter: No such file or directory 
/tmp/hudson3481773306458146820.sh: /usr/local/bin/bundle: /usr/bin/ruby1.9.1: bad interpreter: No such file or directory 
/tmp/hudson3481773306458146820.sh: /usr/local/bin/bundle: /usr/bin/ruby1.9.1: bad interpreter: No such file or directory 
Build step 'Execute shell' marked build as failure 
Warning: you have no plugins providing access control for builds, so falling back to legacy behavior of permitting any downstream builds to be triggered 
Finished: FAILURE 

这里是我的构建脚本:

#!/bin/bash 
source /home/web/.bashrc 
rvm use 2.2.3 
rvm info 
bundle install 
bundle exec rake db:schema:load RAILS_ENV=test 
bundle exec rake db:test:prepare 
bundle exec rspec spec --order random --fail-fast 

,我就做什么很失落,我甚至想指定构建脚本红宝石版本,但它找不到rvm。

这里是我的.bashrc

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" 
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting 

这里是RVM列表的输出:

[email protected]:~$ rvm list 

rvm rubies 

    ruby-2.1.5 [ x86_64 ] 
=* ruby-2.2.3 [ x86_64 ] 

# => - current 
# =* - current && default 
# * - default 

红宝石-v

ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux] 

任何想法是怎么回事?

你有两种选择来解决这个问题,我认为:

  • 对于詹金斯用户安装RVM,就像你对一个开发者。然后你的构建脚本会理解rvm。

  • 安装rvm插件。 (在此之前,我必须安装Jenkins的LTS版本。)然后,您可以将RVM部分从构建脚本中取出并作为一个操作。

我很确定,其中任何一个都可以解决上述问题。你不应该这样做。

(免责声明:我自己是Jenkins的新用户。)

+0

谢谢!这是问题所在,我没有意识到Jenkins是它自己的用户,需要安装RVM。谢谢您的帮助! – ajk4550