Class: Jenkins::Model::Build

Inherits:
Object
  • Object
show all
Defined in:
lib/jenkins/model/build.rb

Overview

Represents a single build. In general, you won’t need this

Defined Under Namespace

Classes: Halt

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(native = nil) ⇒ Build

Returns a new instance of Build.



19
20
21
22
# File 'lib/jenkins/model/build.rb', line 19

def initialize(native = nil)
  @native = native
  @variables = {}
end

Instance Attribute Details

#nativeObject (readonly)

the Hudson::Model::AbstractBuild represented by this build



17
18
19
# File 'lib/jenkins/model/build.rb', line 17

def native
  @native
end

Instance Method Details

#[](key) ⇒ Object

Gets a build value. Each build stores a map of key,value pairs which can be used by each build step in the pipeline

Parameters:

  • key (String|Symbol)

Returns:

  • (Object)

    value



29
30
31
# File 'lib/jenkins/model/build.rb', line 29

def [](key)
  @variables[key.to_s]
end

#[]=(key, value) ⇒ Object

Sets a build value. Each build has a map of key,value pairs which allow build steps to share information

Parameters:

  • key (String|Symbol)
  • value (Object)

Returns:

  • (Object)

    value



39
40
41
# File 'lib/jenkins/model/build.rb', line 39

def []=(key, value)
  @variables[key.to_s] = value
end

#abort(reason = nil) ⇒ Object

Abort the current build, causing a build failure.

Parameters:

  • reason (String) (defaults to: nil)

    the reason for your abort, optional.

Raises:

  • (Java.hudson.AbortException)


57
58
59
# File 'lib/jenkins/model/build.rb', line 57

def abort(reason = nil)
  raise Java.hudson.AbortException.new(reason)
end

#build_varObject



61
62
63
# File 'lib/jenkins/model/build.rb', line 61

def build_var
  @native.getBuildVariables()
end

#build_wrapper_environment(cls) ⇒ Object



69
70
71
72
73
# File 'lib/jenkins/model/build.rb', line 69

def build_wrapper_environment(cls)
  @native.getEnvironmentList().find do |e|
    e.instance_of?(Jenkins::Plugin::Proxies::EnvironmentWrapper) && e.build_wrapper.instance_of?(cls)
  end
end

#envObject



65
66
67
# File 'lib/jenkins/model/build.rb', line 65

def env
  @native.getEnvironment(nil)
end

#halt(reason = nil) ⇒ Object

Halt the current build, without setting the result to failure

Parameters:

  • reason (String) (defaults to: nil)

    the reason for your halt, optional.

Raises:



50
51
52
# File 'lib/jenkins/model/build.rb', line 50

def halt(reason = nil)
  raise Halt, reason
end

#workspaceObject



43
44
45
# File 'lib/jenkins/model/build.rb', line 43

def workspace
  FilePath.new(@native.getWorkspace())
end