Skip to content

Commit

Permalink
Allow for specification of environment variables when bundle-ing via …
Browse files Browse the repository at this point in the history
…the `bundle_env_variables` configuration option.
  • Loading branch information
pjkelly committed Jan 24, 2014
1 parent f1b70e2 commit 18c8385
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# future release

* Added `bundle_env_variables` option for specifying environment variables that should be set when running `bundle`.
* The `bundle_dir` option is now named `bundle_path`
* Use `bundle install` instead of `bundle`
* All options are now optional and can be excluded from the final bundle command by setting them to `nil`
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Configurable options:
set :bundle_path, -> { shared_path.join('bundle') } # this is default
set :bundle_without, %w{development test}.join(' ') # this is default
set :bundle_flags, '--deployment --quiet' # this is default
set :bundle_env_variables, {} # this is default

This would execute the following bundle command on all servers
(actual paths depend on the real deploy directory):
Expand All @@ -57,6 +58,15 @@ This would execute the following bundle command on all servers

If any option is set to `nil` it will be excluded from the final bundle command.

### Environment Variables

The `bundle_env_variables` option can be used to specify any environment variables you want present when running the `bundle` command:

```ruby
# This translates to NOKOGIRI_USE_SYSTEM_LIBRARIES=1 when executed
set :bundle_env_variables, { nokogiri_use_system_libraries: 1 }
```

## Contributing

1. Fork it
Expand Down
19 changes: 11 additions & 8 deletions lib/capistrano/tasks/bundler.cap
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@ namespace :bundler do
set :bundle_path, -> { shared_path.join('bundle') }
set :bundle_without, %w{development test}.join(' ')
set :bundle_flags, '--deployment --quiet'
set :bundle_env_variables, {}
DESC
task :install do
on roles fetch(:bundle_roles) do
within release_path do
options = ["install"]
options << "--binstubs #{fetch(:bundle_binstubs)}" if fetch(:bundle_binstubs)
options << "--gemfile #{fetch(:bundle_gemfile)}" if fetch(:bundle_gemfile)
options << "--path #{fetch(:bundle_path)}" if fetch(:bundle_path)
options << "--without #{fetch(:bundle_without)}" if fetch(:bundle_without)
options << "#{fetch(:bundle_flags)}" if fetch(:bundle_flags)

execute :bundle, options
with fetch(:bundle_env_variables, {}) do
options = ["install"]
options << "--binstubs #{fetch(:bundle_binstubs)}" if fetch(:bundle_binstubs)
options << "--gemfile #{fetch(:bundle_gemfile)}" if fetch(:bundle_gemfile)
options << "--path #{fetch(:bundle_path)}" if fetch(:bundle_path)
options << "--without #{fetch(:bundle_without)}" if fetch(:bundle_without)
options << "#{fetch(:bundle_flags)}" if fetch(:bundle_flags)

execute :bundle, options
end
end
end
end
Expand Down

0 comments on commit 18c8385

Please sign in to comment.