Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ configure for your application with Capistrano.
set :password, "admin"
set :stage, "test" # specify the stage you want to deploy
set :webistrano_home, "http://webistrano.mydomain.com"
set :host_to_deploy, "server-name-here" #if you wish to override the host

If you only have one stage in your project this should do, however with
several stages it'd be better to ask for the stage to be deployed:
Expand Down
12 changes: 12 additions & 0 deletions lib/cap_ext_webistrano/host.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Host < ActiveResource::Base
def self.configure(config)
Host.site = config[:webistrano_home]
Host.user = config[:user]
Host.password = config[:password]
end

def self.find_by_name(name)
host = find(:all).find {|host| host.name == name}
end

end
16 changes: 14 additions & 2 deletions lib/cap_ext_webistrano/task.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'cap_ext_webistrano/project'
require 'cap_ext_webistrano/stage'
require 'cap_ext_webistrano/deployment'
require 'cap_ext_webistrano/host'

module CapExtWebistrano
class Task
Expand All @@ -13,7 +14,7 @@ def initialize(task, config)
end

def set_access_data
[Project, Stage, Deployment].each do |klazz|
[Project, Stage, Deployment, Host].each do |klazz|
klazz.configure(@config)
end
end
Expand Down Expand Up @@ -43,7 +44,18 @@ def run
set_access_data
@project = Project.find_by_name(@config[:application])
@stage = @project.find_stage(@config[:stage])
params = { :task => task, :stage_id => @stage.id, :project_id => @project.id, :description => @config[:description] }
params = {}

if @config[:host_to_deploy]
hosts_all = Host.all
host_to_deploy = Host.find_by_name(@config[:host_to_deploy])
do_not_deploy_hosts = hosts_all - [host_to_deploy]
hosts_ids = do_not_deploy_hosts.collect {|h| h.id}
params = { :task => task, :stage_id => @stage.id, :project_id => @project.id, :description => @config[:description], :excluded_host_ids => hosts_ids }
else
params = { :task => task, :stage_id => @stage.id, :project_id => @project.id, :description => @config[:description]}
end

params.merge!(:prompt_config => @config[:prompt_config]) if @config.exists?(:prompt_config)
@deployment = Deployment.create(params)
loop_latest_deployment
Expand Down