Skip to content

Commit

Permalink
Fixes #84: Fail CodeDeploy outside of InteractiveLogger Step (#143)
Browse files Browse the repository at this point in the history
The raise inside of the step was losing the previous failure message.
  • Loading branch information
askreet committed Oct 10, 2016
1 parent d5640b2 commit f4e49e2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/moonshot/deployment_mechanism/code_deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def status_hook
end

def deploy_hook(artifact_repo, version_name)
success = true
deployment_id = nil

ilog.start_threaded 'Creating Deployment' do |s|
res = cd_client.create_deployment(
application_name: app_name,
Expand All @@ -76,8 +79,10 @@ def deploy_hook(artifact_repo, version_name)
)
deployment_id = res.deployment_id
s.continue "Created Deployment #{deployment_id.blue}."
wait_for_deployment(deployment_id, s)
success = wait_for_deployment(deployment_id, s)
end

handle_deployment_failure(deployment_id) unless success
end

def post_delete_hook
Expand Down Expand Up @@ -260,6 +265,8 @@ def wait_for_asg_capacity
end

def wait_for_deployment(id, step)
success = true

loop do
sleep 5
info = cd_client.get_deployment(deployment_id: id).deployment_info
Expand All @@ -273,9 +280,12 @@ def wait_for_deployment(id, step)
break
when 'Failed', 'Stopped'
step.failure "Deployment #{id.blue} failed with status '#{status}'"
handle_deployment_failure(id)
success = false
break
end
end

success
end

def handle_deployment_failure(deployment_id)
Expand Down

0 comments on commit f4e49e2

Please sign in to comment.