Class: Jenkins::Model::Build
- Inherits:
-
Object
- Object
- Jenkins::Model::Build
- Includes:
- Plugin::Wrapper
- Defined in:
- lib/jenkins/model/build.rb
Overview
Represents a single build. This object is passed in to all build steps, and can be used to configure, halt, message the current running build.
Defined Under Namespace
Classes: EnvironmentVariables, Halt
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Hash of environment variables that will be added to each process started as part of this build.
Attributes included from Plugin::Wrapper
Instance Method Summary collapse
-
#[](key) ⇒ Object
Gets a build value.
-
#[]=(key, value) ⇒ Object
Sets a build value.
-
#abort(reason = nil) ⇒ Object
Abort the current build, causing a build failure.
-
#halt(reason = nil) ⇒ Object
Halt the current build, without setting the result to failure.
-
#initialize(native) ⇒ Build
constructor
A new instance of Build.
-
#workspace ⇒ Jenkins::FilePath
The workspace associated with this build.
Methods included from Plugin::Behavior
extended, #implemented, #included
Methods included from Plugin::Behavior::BehavesAs
Constructor Details
#initialize(native) ⇒ Build
Returns a new instance of Build.
31 32 33 34 35 36 |
# File 'lib/jenkins/model/build.rb', line 31 def initialize(native) super(native) @variables = {} @env = {} @native.buildEnvironments.add(EnvironmentVariables.new(@env)) end |
Instance Attribute Details
#env ⇒ Object (readonly)
Hash of environment variables that will be added to each process started as part of this build. E.g.
build.env = ‘/path/to/my/gem/home’
Note that this is not an exhaustive list of all environment variables, only those which have been explicitly set by code inside this Ruby plugin.
Also, this list does not contain variables that might get set by things like .profile and .rc files.
29 30 31 |
# File 'lib/jenkins/model/build.rb', line 29 def env @env 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
43 44 45 |
# File 'lib/jenkins/model/build.rb', line 43 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
53 54 55 |
# File 'lib/jenkins/model/build.rb', line 53 def []=(key, value) @variables[key.to_s] = value end |
#abort(reason = nil) ⇒ Object
Abort the current build, causing a build failure.
73 74 75 |
# File 'lib/jenkins/model/build.rb', line 73 def abort(reason = nil) raise Java.hudson.AbortException.new(reason) end |
#halt(reason = nil) ⇒ Object
Halt the current build, without setting the result to failure
66 67 68 |
# File 'lib/jenkins/model/build.rb', line 66 def halt(reason = nil) raise Halt, reason end |
#workspace ⇒ Jenkins::FilePath
The workspace associated with this build
59 60 61 |
# File 'lib/jenkins/model/build.rb', line 59 def workspace FilePath.new(@native.getWorkspace()) end |