class Pushwagner::Maven::Deployer

Deployer strategy for maven repos (wip).

Attributes

artifacts[R]
environment[R]
repository[R]

Public Class Methods

new(env, opts = {}) click to toggle source
# File lib/pushwagner/maven.rb, line 113
def initialize(env, opts = {})
  @environment = env
  # TODO: nil-object instead?
  @artifacts = env.maven? ? env.maven.artifacts : {}
  @repository = env.maven? ? env.maven.repository : nil
end

Public Instance Methods

deploy() click to toggle source
# File lib/pushwagner/maven.rb, line 120
def deploy
  artifacts.each do |name, artifact|
    environment.hosts.each do |host|
      Pushwagner.info "Deploying #{name}, #{artifact} to #{host}"

      mark_previous(name, host)
      pull_artifact(name, artifact, host)
      mark_new(name, artifact, host)

    end
  end
  true # false if failed
end

Protected Instance Methods

mark_new(name, artifact, host) click to toggle source
# File lib/pushwagner/maven.rb, line 152
def mark_new(name, artifact, host)
  Net::SSH.start(host, environment.user) do |ssh|
    Pushwagner.begin_info "Marking #{artifact.jar_name} as current on #{host}"
    ssh.exec("ln -sf #{environment.path_prefix}/#{name}/#{artifact.jar_name} #{environment.path_prefix}/#{name}/#{name}.jar")
    Pushwagner.ok
  end
end
mark_previous(name, host) click to toggle source
# File lib/pushwagner/maven.rb, line 144
def mark_previous(name, host)
  Net::SSH.start(host, environment.user) do |ssh|
    Pushwagner.begin_info "Marking previous release on #{host}"
    ssh.exec("cp -P #{environment.path_prefix}/#{name}/#{name}.jar #{environment.path_prefix}/#{name}/#{name}.previous.jar")
    Pushwagner.ok
  end
end
pull_artifact(name, artifact, host) click to toggle source
# File lib/pushwagner/maven.rb, line 136
def pull_artifact(name, artifact, host)
  Net::SSH.start(host, environment.user) do |ssh|
    Pushwagner.begin_info "Pulling #{repository.absolute_url(artifact)} to #{host}:#{environment.path_prefix}/#{artifact.jar_name}"
    ssh.exec("curl --user '#{repository.authentication(artifact.snapshot?)}' #{repository.absolute_url(artifact)} > #{environment.path_prefix}/#{name}/#{artifact.jar_name}")
    Pushwagner.ok
  end
end