OK, now I am stuck in something interesting...
My logic to achieve the above said requirement is as follows:
You call "cap -S config=blah -S svn-repo=both my_deploy"
The code in deploy.rb is as such:
task :my_deploy do
init_server_list { deploy.default }
end
def init_server_list(&given_task)
# if svn repo name is given, get ip from there.
if variables.include?(:svn_repo) and svn_repo == "both"
# get all repo names, call deployer for every unique name.
con = Mysql.new(db_host, db_user, db_pass, db_schema)
rs = con.query("SELECT DISTINCT _nick_name FROM repo;")
rs.each do |row|
set :repo_name, row[0]
get_server_list given_task
end
con.close
end
end
def get_server_list(action)
con = Mysql.new(db_host, db_user, db_pass, db_schema)
query = "select
server.`_ip` as ip,
repo.`_svn_url` as repo_url
from
server
left join repo
on repo.`_id` = server.`_repo_id`
where repo.`_nick_name` = '#{repo_name}'";
rs = con.query(query)
roles[:app].clear
rs.each do |row|
role :app, row[0]
set :repository, row[1]
end
con.close
action.call
end
# Unnecessary code removed and/or obfuscated, but assure that no harm done to hinder debugging.
Now the logic is that it should loop through for every repository, get the list of servers to be updated for that repository and update the code.
All is well, it runs smoothly for every server and all... But...
When it comes to updating the svn repo, it is pushing the same repo that it got first time.
It seemed that the "svn checkout" command is cached somewhere...
Further debugging, I went into "strategy/checkout.rb" inside capistrano's code.
def command
@command || = source.checkout(revision, configuration[:release_path])
end
Remove the '||' there, it works well... I wouldn't like to touch original capistrano code unless absolutely necessary. So, is there a way to unset the command variable from my recipe or any better way?
Any suggestions towards the architecture or a solution would be welcome...