我正在尝试设置Jenkins以构建然后部署我的rails应用程序,但我的构建仍然失败。这是因为Jenkins正在查看错误的Ruby版本而不使用RVM。这是构建失败日志:
/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
我很遗憾该怎么做,我甚至试图在构建脚本中指定ruby版本,但它找不到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 list的输出:
web@localhost:~$ rvm list
rvm rubies
ruby-2.1.5 [ x86_64 ]
=* ruby-2.2.3 [ x86_64 ]
# => - current
# =* - current && default
# * - default
ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]
知道出了什么问题吗?
答案 0 :(得分:1)
我认为你有两种方法可以解决这个问题:
为jenkins用户安装RVM,就像开发人员一样。然后你的构建脚本将理解rvm。
安装rvm插件。 (我必须先安装LTS版本的Jenkins才能使用。)然后你可以从构建脚本中取出RVM部分并使其成为一个动作。
我很确定其中任何一个都能解决上述问题。你不应该同时做这两件事。
(免责声明:詹金斯本人的新手。)