我正在尝试在容器化的CI环境中激活JRuby,这些机器正在运行Ubuntu:Linux-3.13.0-91-generic-x86_64-with-Ubuntu-12.04-precise
,特别是我有一个创建WAR文件的脚本:
#!/bin/bash --login
if [ "$1" == "" ]; then
BUILD_ENV="production"
else
BUILD_ENV="$1"
fi
echo "Building for: $BUILD_ENV"
rvm install jruby-9.1.2.0
rvm use jruby-9.1.2.0
rvm get head
function nightly_ci() {
if [[ "$(python -mplatform)" =~ .*Ubuntu*. ]]; then
export PATH="$PATH:$HOME/.rvm/scripts/rvm"
chmod 755 ~/.rvm ~/.bashrc && echo rvm_autoupdate_flag=0 >> ~/.rvmrc
printf '%s' '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc
fi
}
nightly_ci
# install and package all gems (fixes issues with :gem/:ref gemfile)
echo "bundle install --without development test profile"
bundle install --without development test profile
echo "bundle package --all"
bundle package --all
# build war file, smartroom.war
echo "RAILS_ENV=$BUILD_ENV bundle exec rake assets:precompile"
RAILS_ENV=$BUILD_ENV bundle exec rake assets:precompile --trace
echo "RAILS_ENV=$BUILD_ENV bundle exec warble war"
RAILS_ENV=$BUILD_ENV bundle exec warble war --trace
这在localhost上运行良好,并且将在容器化环境上运行,但只能在从命令行显式调用JRuby解释器之后运行。
例如,我运行我的脚本运行下载JRuby,确保路径设置正确,bundle安装必要的gem,然后生成WAR。但是,这在容器化环境中不起作用,因为bundle install使用本机Ruby版本中的gem,并且不会将正确的gem安装到JRuby中。如果我在脚本执行后键入rvm install jruby-9.1.2.0
它将告诉我JRuby已经安装然后如果我重新运行脚本它完全正常。我认为我的bash配置文件是可能的配置错误,但似乎并非如此。这是我在容器上的bashrc:
source ~/.circlerc &>/dev/null
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
# The next line updates PATH for the Google Cloud SDK.
source '/opt/google-cloud-sdk/path.bash.inc'
# The next line enables shell command completion for gcloud.
source '/opt/google-cloud-sdk/completion.bash.inc'
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
我的.profile:
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
我的JRuby版本:jruby 9.1.2.0 (2.3.0) 2016-05-26 7357c8f Java HotSpot(TM) 64-Bit Server VM 24.76-b04 on 1.7.0_76-b13 +jit [linux-x86_64]
最后,我尝试通过shell以编程方式调用确切的命令集(这需要完成,因为我试图在夜间构建期间自动生成WAR),脚本完成后再重新启动脚本并没有用。我希望你们可能有一些见解。
答案 0 :(得分:0)
通过更改执行程序包脚本的循环阶段解决了这个问题我确定这是rvm 1.26.10的问题。