我在 jenkins 中执行 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
我做错了什么,我该如何解决这个问题?