I've written a gem elastic-beanstalk which is to be used inside a rails project file structure, as well as in a standalone CI environment where the rails dir and files are not available (without unzipping etc). i.e. the Bamboo build process running eb:package will yield one primary artifact app.zip where the deploy plan at a later time and perhaps on another agent can take over and execute eb:deploy.
The goal
This is all running fine when inside a rails project structure, so my goal here is to also get this running for the standalone CI environment.
Given
an empty dir (CI environment) with just the app.zip, eb.yml, binstubs created, and the gem is available
When
I run elastic-beanstalk eb:deploy
Then
it should run the equivalent of rake eb:deploy using this gem's dependencies and lib files.
Update - Bin Stub
It appears that a bin stub may be what I'm looking for. Exploring another SO post, I have tried (to no avail so far) bin/elastic-beanstalk:
gem_dir = File.expand_path('..',File.dirname(__FILE__))
$LOAD_PATH.unshift gem_dir# Look in gem directory for resources first.
lib = File.expand_path('lib', gem_dir)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'elastic/beanstalk'
require 'rake'
require 'pp'
pwd=Dir.pwd
Dir.chdir("#{gem_dir}/bin") # We'll load rakefile from the gem's bin dir.
Rake.application.init
Rake.application.load_rakefile
Dir.chdir(pwd) # Revert to original pwd for any path args passed to task.
Rake.application.invoke_task(ARGV[0])
So this runs, but is still failing with the same dependency problem I began with undefined method 'safe_load_file' for Psych:Module (NoMethodError). While I think a binstub is the way to go: