Module: Bozo::Runner

Includes:
Logging
Included in:
Executor
Defined in:
lib/bozo/runner.rb

Overview

Module mixed into the all Bozo executors that provides functionality for command execution and logging.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

#log_debug, #log_fatal, #log_info, #log_warn

Instance Attribute Details

#build_configurationObject

Returns the build configuration.



19
20
21
# File 'lib/bozo/runner.rb', line 19

def build_configuration
  @build_configuration
end

#envObject

Returns the environment variables.



16
17
18
# File 'lib/bozo/runner.rb', line 16

def env
  @env
end

#global_paramsObject

Returns the global parameters.



10
11
12
# File 'lib/bozo/runner.rb', line 10

def global_params
  @global_params
end

#paramsObject

Returns the command parameters.



13
14
15
# File 'lib/bozo/runner.rb', line 13

def params
  @params
end

Instance Method Details

#build_server?Boolean

Returns whether the build is being run on a build server.

Returns:

  • (Boolean)


22
23
24
# File 'lib/bozo/runner.rb', line 22

def build_server?
  global_params[:build_server]
end

#environmentObject

Returns the environment the build is being execute in.



32
33
34
# File 'lib/bozo/runner.rb', line 32

def environment
  global_params[:environment]
end

#execute_command(tool, args) ⇒ Object

Executes a command line tool.

Raises a ‘Bozo::ExecutionError` if the command responds with a non-zero exit code.

Parameters:

  • tool (Symbol)

    A friendly identifier for the tool.

  • args (Array)

    An array of arguments making up the command to execute.

Raises:



45
46
47
48
49
50
51
52
53
54
# File 'lib/bozo/runner.rb', line 45

def execute_command(tool, args)
  args.flatten!

  executable = File.basename(args.first)
  arguments = args[1..-1].join(' ')

  log_info "  #{tool} - #{executable} #{arguments}"

  raise Bozo::ExecutionError.new(tool, args, $?.exitstatus) unless system args.join ' '
end

#pre_release?Boolean

Returns whether a pre release should be created.

Returns:

  • (Boolean)


27
28
29
# File 'lib/bozo/runner.rb', line 27

def pre_release?
  params[:pre_release]
end

#versionObject

Returns the build version.



57
58
59
# File 'lib/bozo/runner.rb', line 57

def version
  build_configuration.version
end