Method: Docman::Application#execute

Defined in:
lib/application.rb

#execute(action, state, name = nil, tag = nil) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/application.rb', line 71

def execute(action, state, name = nil, tag = nil)
  params = Marshal.load(Marshal.dump(@deploy_target))
  failed_filepath = File.join(@workspace_dir, 'failed')
  if File.file?(failed_filepath)
    log 'Last operation failed, forced rebuild mode'
    FileUtils.rm_f failed_filepath
    @force = true
  end
  params['state'] = state
  params['action'] = action
  params['name'] = name
  params['tag'] = tag
  params['environment'] = @config['environments'][@deploy_target['states'][state]]
  params['environment_name'] = @deploy_target['states'][state]
  Docman::Deployers::Deployer.create(params, nil, self).perform
rescue Exception => e
  log "Operation failed: #{e.message}", 'error'
  File.open(failed_filepath, 'w') {|f| f.write('Failed!') }
end