Created
March 22, 2011 14:46
-
-
Save gotascii/881320 to your computer and use it in GitHub Desktop.
cc.rb auto-deployer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This plugin will deploy your app using capistrano. | |
# If the build fails the app won't de be deployed and if it passes it will try to deploy to a list of stages you can supply. | |
# | |
# Configuration | |
# In your project's cruise_config.rb file: | |
# | |
# Pass an array of stages you want to deploy to | |
# project.cap_deployer.stages = ['integration', 'staging'] | |
# | |
# source ~/.rvm/scripts/rvm before deployment? | |
# default: true | |
# project.cap_deployer.rvm = false | |
# | |
# Important: this plugin assumes you are using ssh keys for deployment | |
# | |
class SimpleDeployer | |
attr_accessor :stages, :rvm | |
def initialize(project = nil) | |
@stages = [] | |
@rvm = true | |
end | |
def build_finished(build) | |
return if build.failed? | |
deploy build | |
end | |
private | |
def deploy(build) | |
work_path = build.project.path + "/work/" | |
log_path = build.artifacts_directory | |
@stages.each do |stage| | |
cmd = ["cd #{work_path}", "cap -l #{log_path}/cap_deploy_#{stage}.txt #{stage} deploy:migrations"] | |
cmd.unshift("source ~/.rvm/scripts/rvm") if rvm | |
`bash -c '#{cmd.join(" && ")}'` | |
end | |
end | |
end | |
Project.plugin :simple_deployer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment