Class: AvoDeploy::Task::TaskExecutionEnvironment

Inherits:
Object
  • Object
show all
Defined in:
lib/avodeploy/task/task_execution_environment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ TaskExecutionEnvironment

Initialized the environment

Parameters:

  • config (Hash)

    deployment configuration



29
30
31
32
# File 'lib/avodeploy/task/task_execution_environment.rb', line 29

def initialize(config)
  # @todo check
  @config = config
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



24
25
26
# File 'lib/avodeploy/task/task_execution_environment.rb', line 24

def options
  @options
end

#scmObject

Returns the value of attribute scm.



23
24
25
# File 'lib/avodeploy/task/task_execution_environment.rb', line 23

def scm
  @scm
end

Instance Method Details

#check_util_availability(utils, system_name) ⇒ Object

Checks, if all utilities are available for the deployment process to be executed

Parameters:

  • utils (Array)

    array with utilities to check



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/avodeploy/task/task_execution_environment.rb', line 53

def check_util_availability(utils, system_name)
  begin
    utils.each do |util|
      if command("command -v #{util} >/dev/null 2>&1 || exit 1;").retval == 1
        msg = "command line utility '#{util}' is not installed #{system_name}"

        raise RuntimeError, msg
      end
    end
  rescue Exception => e
    handle_abort e
  end
end

#get(key) ⇒ mixed

Returns a configuration item if set

Parameters:

  • key (Symbol)

    configuration key

Returns:

  • (mixed)

    configuration value



86
87
88
# File 'lib/avodeploy/task/task_execution_environment.rb', line 86

def get(key)
  @config[key]
end

#handle_abort(e) ⇒ Object

Shorthand for exception handling

Parameters:

  • e (Exception)

    the exception to handle



93
94
95
# File 'lib/avodeploy/task/task_execution_environment.rb', line 93

def handle_abort(e)
  AvoDeploy::Deployment.instance.handle_abort(e)
end

#logLogger

Returns the logger instance

Returns:

  • (Logger)

    log instance



70
71
72
# File 'lib/avodeploy/task/task_execution_environment.rb', line 70

def log
  AvoDeploy::Deployment.instance.log
end

#run(task_name) ⇒ Object

Runs a task chain

Parameters:

  • task_name (Symbol)

    task name to invoke



45
46
47
# File 'lib/avodeploy/task/task_execution_environment.rb', line 45

def run(task_name)
  AvoDeploy::Deployment.instance.task_manager.invoke_task_chain_containing(task_name)
end

#run_nodeps(task_name) ⇒ Object

Runs a task without dependencies

Parameters:

  • task_name (Symbol)

    task name to execute

Returns:

  • (Object)

    the task result



38
39
40
# File 'lib/avodeploy/task/task_execution_environment.rb', line 38

def run_nodeps(task_name)
  AvoDeploy::Deployment.instance.task_manager.invoke_task_oneshot(task_name)
end

#set(key, value) ⇒ Object

Sets a configuration item

Parameters:

  • key (Symbol)

    configuration key

  • value (mixed)

    configuration value



78
79
80
# File 'lib/avodeploy/task/task_execution_environment.rb', line 78

def set(key, value)
  @config[key] = value
end