Class: CiCd::Builder::BuilderBase

Inherits:
Object
  • Object
show all
Defined in:
lib/cicd/builder.rb

Overview

noinspection ALL

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBuilderBase

Returns a new instance of BuilderBase.



32
33
34
35
36
37
38
39
40
# File 'lib/cicd/builder.rb', line 32

def initialize()
     @vars = {
         return_code: -1
     }
	@default_options = {
			builder:        ::CiCd::Builder::VERSION,
			env_keys:       %w(JENKINS_HOME BUILD_NUMBER JOB_NAME)
	}
end

Instance Attribute Details

#default_optionsObject

Returns the value of attribute default_options.



27
28
29
# File 'lib/cicd/builder.rb', line 27

def default_options
  @default_options
end

#loggerObject

Returns the value of attribute logger.



29
30
31
# File 'lib/cicd/builder.rb', line 29

def logger
  @logger
end

#optionsObject

Returns the value of attribute options.



28
29
30
# File 'lib/cicd/builder.rb', line 28

def options
  @options
end

#varsObject

Returns the value of attribute vars.



30
31
32
# File 'lib/cicd/builder.rb', line 30

def vars
  @vars
end

Instance Method Details

#getBuilderVersionObject




50
51
52
53
54
55
56
57
# File 'lib/cicd/builder.rb', line 50

def getBuilderVersion
  {
      version:  VERSION,
      major:    MAJOR,
      minor:    MINOR,
      patch:    PATCH,
  }
end

#runObject




67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/cicd/builder.rb', line 67

def run()
	setup()

     ret = 0
	%w(checkEnvironment getVars prepareBuild makeBuild saveBuild uploadBuildArtifacts).each do |step|
       @logger.step "#{step}"
       ret = send(step)
       break unless ret == 0
     end

	@vars[:return_code]
end

#setupObject




60
61
62
63
64
# File 'lib/cicd/builder.rb', line 60

def setup()
	$stdout.write("CiCd::Builder v#{VERSION}\n")
     @default_options[:env_keys] = Hash[@default_options[:env_keys].flatten.map.with_index.to_a].keys
	parseOptions()
end