我如何在ubuntu的jenkins中运行jruby



我有一个问题,从詹金斯内部执行bash脚本。我选中了shell命令,我的输入如下:

rvm use jruby-1.7.4
export JRUBY_OPTS=--1.8
jruby -S cucumber

仅供参考:这3个命令正是我在Jenkins之外启动cucumber时在终端中键入的。

当我执行这些命令时,这是我的输出

[workspace] $ /bin/sh -xe /home/nwssc/apache-tomcat-7.0.40/temp/hudson7305254619895710829.sh
+ rvm use jruby-1.7.4
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for a example.
+ export JRUBY_OPTS=--1.8
+ jruby -S cucumber
/home/nwssc/apache-tomcat-7.0.40/temp/hudson7305254619895710829.sh: 4: /home/nwssc/apache-tomcat-7.0.40/temp/hudson7305254619895710829.sh: jruby: not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE

所以我用/bin/bash——login作为脚本的第一个命令来执行,我仍然得到

[workspace] $ /bin/sh -xe /home/nwssc/apache-tomcat-7.0.40/temp/hudson7981126593924329573.sh
+ /bin/bash --login
+ rvm use jruby-1.7.4
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for a example.
+ export JRUBY_OPTS=--1.8
+ jruby -S cucumber
/home/nwssc/apache-tomcat-7.0.40/temp/hudson7981126593924329573.sh: 5: /home/nwssc/apache-tomcat-7.0.40/temp/hudson7981126593924329573.sh: jruby: not found
Build step 'Execute shell' marked build as failure

所以我尝试使用RVM插件并将其设置为使用jruby 1.7.4,这是结果

Capturing environment variables produced by 'rvm use jruby-1.7.4'
$ bash -c export
$ bash -c "test -f ~/.rvm/scripts/rvm"
$ bash -c "test -f /usr/local/rvm/scripts/rvm"
[workspace] $ bash -c " source /usr/local/rvm/scripts/rvm && rvm use --install --create jruby-1.7.4 && export > rvm.env"
Using /usr/local/rvm/gems/jruby-1.7.4
[workspace] $ /bin/sh -xe /home/nwssc/apache-tomcat-7.0.40/temp/hudson661746741998327634.sh
+ export JRUBY_OPTS=--1.8
+ jruby -S cucumber
/home/nwssc/apache-tomcat-7.0.40/temp/hudson661746741998327634.sh: 3: /home/nwssc/apache-tomcat-7.0.40/temp/hudson661746741998327634.sh: jruby: not found
Build step 'Execute shell' marked build as failure

我做错了什么,我该如何解决这个问题?

重新加载bashrc或bash_profile以确保RVM正在被加载

/bin/bash --login
source ~/.bashrc
source ~/.bash_profile
rvm use jruby-1.7.4

my bashrc有这个

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

bash_profile有这个

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

最新更新