Class: Artifactory::Resource::Build
- Defined in:
- lib/artifactory/resources/build.rb
Constant Summary collapse
- BUILD_SCHEMA_VERSION =
"1.0.1".freeze
- BUILD_TYPES =
valid build types as dictated by the Artifactory API
%w{ ANT IVY MAVEN GENERIC GRADLE }.freeze
Class Method Summary collapse
-
.all(name, options = {}) ⇒ Array<Resource::Build>
Search for all builds in the system.
-
.find(name, number, options = {}) ⇒ Resource::Build?
Find (fetch) data for a particular build of a component.
- .from_hash(hash, options = {}) ⇒ Object
Instance Method Summary collapse
-
#agent ⇒ Object
Return this object’s
agent
. -
#agent=(value) ⇒ Object
Set this object’s
agent
. -
#agent? ⇒ Boolean
Determines if the
agent
value exists and is truthy. -
#artifactory_principal ⇒ Object
Return this object’s
artifactory_principal
. -
#artifactory_principal=(value) ⇒ Object
Set this object’s
artifactory_principal
. -
#artifactory_principal? ⇒ Boolean
Determines if the
artifactory_principal
value exists and is truthy. -
#build_agent ⇒ Object
Return this object’s
build_agent
. -
#build_agent=(value) ⇒ Object
Set this object’s
build_agent
. -
#build_agent? ⇒ Boolean
Determines if the
build_agent
value exists and is truthy. -
#build_retention ⇒ Object
Return this object’s
build_retention
. -
#build_retention=(value) ⇒ Object
Set this object’s
build_retention
. -
#build_retention? ⇒ Boolean
Determines if the
build_retention
value exists and is truthy. -
#diff(previous_build_number) ⇒ Hash<String, Hash>
Compare a build artifacts/dependencies/environment with an older build to see what has changed (new artifacts added, old dependencies deleted etc).
-
#duration_millis ⇒ Object
Return this object’s
duration_millis
. -
#duration_millis=(value) ⇒ Object
Set this object’s
duration_millis
. -
#duration_millis? ⇒ Boolean
Determines if the
duration_millis
value exists and is truthy. -
#governance ⇒ Object
Return this object’s
governance
. -
#governance=(value) ⇒ Object
Set this object’s
governance
. -
#governance? ⇒ Boolean
Determines if the
governance
value exists and is truthy. -
#license_control ⇒ Object
Return this object’s
license_control
. -
#license_control=(value) ⇒ Object
Set this object’s
license_control
. -
#license_control? ⇒ Boolean
Determines if the
license_control
value exists and is truthy. -
#modules ⇒ Object
Return this object’s
modules
. -
#modules=(value) ⇒ Object
Set this object’s
modules
. -
#modules? ⇒ Boolean
Determines if the
modules
value exists and is truthy. -
#name ⇒ Object
Return this object’s
name
. -
#name=(value) ⇒ Object
Set this object’s
name
. -
#name? ⇒ Boolean
Determines if the
name
value exists and is truthy. -
#number ⇒ Object
Return this object’s
number
. -
#number=(value) ⇒ Object
Set this object’s
number
. -
#number? ⇒ Boolean
Determines if the
number
value exists and is truthy. -
#promote(target_repo, options = {}) ⇒ Hash
Move a build’s artifacts to a new repository optionally moving or copying the build’s dependencies to the target repository and setting properties on promoted artifacts.
-
#properties ⇒ Object
Return this object’s
properties
. -
#properties=(value) ⇒ Object
Set this object’s
properties
. -
#properties? ⇒ Boolean
Determines if the
properties
value exists and is truthy. -
#save ⇒ Boolean
Creates data about a build.
-
#started ⇒ Object
Return this object’s
started
. -
#started=(value) ⇒ Object
Set this object’s
started
. -
#started? ⇒ Boolean
Determines if the
started
value exists and is truthy. -
#statuses ⇒ Object
Return this object’s
statuses
. -
#statuses=(value) ⇒ Object
Set this object’s
statuses
. -
#statuses? ⇒ Boolean
Determines if the
statuses
value exists and is truthy. -
#type ⇒ Object
Return this object’s
type
. -
#type=(value) ⇒ Object
Set this object’s
type
. -
#type? ⇒ Boolean
Determines if the
type
value exists and is truthy. -
#url ⇒ Object
Return this object’s
url
. -
#url=(value) ⇒ Object
Set this object’s
url
. -
#url? ⇒ Boolean
Determines if the
url
value exists and is truthy. -
#vcs_revision ⇒ Object
Return this object’s
vcs_revision
. -
#vcs_revision=(value) ⇒ Object
Set this object’s
vcs_revision
. -
#vcs_revision? ⇒ Boolean
Determines if the
vcs_revision
value exists and is truthy. -
#vcs_url ⇒ Object
Return this object’s
vcs_url
. -
#vcs_url=(value) ⇒ Object
Set this object’s
vcs_url
. -
#vcs_url? ⇒ Boolean
Determines if the
vcs_url
value exists and is truthy. -
#version ⇒ Object
Return this object’s
version
. -
#version=(value) ⇒ Object
Set this object’s
version
. -
#version? ⇒ Boolean
Determines if the
version
value exists and is truthy.
Methods inherited from Base
attribute, attributes, #attributes, #client, #client=, #client?, #extract_client!, extract_client!, find_from_config, format_repos!, #format_repos!, from_url, has_attribute?, #initialize, #inspect, list_from_config, #set, #to_hash, #to_json, #to_matrix_properties, #to_query_string_parameters, #to_s, uri_parser, #url_safe, url_safe
Constructor Details
This class inherits a constructor from Artifactory::Resource::Base
Class Method Details
.all(name, options = {}) ⇒ Array<Resource::Build>
Search for all builds in the system.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/artifactory/resources/build.rb', line 40 def all(name, = {}) client = extract_client!() client.get("/api/build/#{url_safe(name)}")["buildsNumbers"].map do |build_number| # Remove the leading / from the `uri` value. Converts `/484` to `484`. number = build_number["uri"].slice(1..-1) find(name, number, client: client) end.compact.flatten rescue Error::HTTPError => e # Artifactory returns a 404 instead of an empty list when there are no # builds. Whoever decided that was a good idea clearly doesn't # understand the point of REST interfaces... raise unless e.code == 404 [] end |
.find(name, number, options = {}) ⇒ Resource::Build?
Find (fetch) data for a particular build of a component
76 77 78 79 80 81 82 83 84 |
# File 'lib/artifactory/resources/build.rb', line 76 def find(name, number, = {}) client = extract_client!() response = client.get("/api/build/#{url_safe(name)}/#{url_safe(number)}") from_hash(response["buildInfo"], client: client) rescue Error::HTTPError => e raise unless e.code == 404 nil end |
.from_hash(hash, options = {}) ⇒ Object
89 90 91 92 93 94 |
# File 'lib/artifactory/resources/build.rb', line 89 def from_hash(hash, = {}) super.tap do |instance| instance.started = Time.parse(instance.started) rescue nil instance.duration_millis = instance.duration_millis.to_i end end |
Instance Method Details
#agent ⇒ Object
Return this object’s agent
104 |
# File 'lib/artifactory/resources/build.rb', line 104 attribute :agent, {} |
#agent=(value) ⇒ Object
Set this object’s agent
104 |
# File 'lib/artifactory/resources/build.rb', line 104 attribute :agent, {} |
#agent? ⇒ Boolean
Determines if the agent
value exists and is truthy
104 |
# File 'lib/artifactory/resources/build.rb', line 104 attribute :agent, {} |
#artifactory_principal ⇒ Object
Return this object’s artifactory_principal
107 |
# File 'lib/artifactory/resources/build.rb', line 107 attribute :artifactory_principal |
#artifactory_principal=(value) ⇒ Object
Set this object’s artifactory_principal
107 |
# File 'lib/artifactory/resources/build.rb', line 107 attribute :artifactory_principal |
#artifactory_principal? ⇒ Boolean
Determines if the artifactory_principal
value exists and is truthy
107 |
# File 'lib/artifactory/resources/build.rb', line 107 attribute :artifactory_principal |
#build_agent ⇒ Object
Return this object’s build_agent
103 |
# File 'lib/artifactory/resources/build.rb', line 103 attribute :build_agent, {} |
#build_agent=(value) ⇒ Object
Set this object’s build_agent
103 |
# File 'lib/artifactory/resources/build.rb', line 103 attribute :build_agent, {} |
#build_agent? ⇒ Boolean
Determines if the build_agent
value exists and is truthy
103 |
# File 'lib/artifactory/resources/build.rb', line 103 attribute :build_agent, {} |
#build_retention ⇒ Object
Return this object’s build_retention
112 |
# File 'lib/artifactory/resources/build.rb', line 112 attribute :build_retention, {} |
#build_retention=(value) ⇒ Object
Set this object’s build_retention
112 |
# File 'lib/artifactory/resources/build.rb', line 112 attribute :build_retention, {} |
#build_retention? ⇒ Boolean
Determines if the build_retention
value exists and is truthy
112 |
# File 'lib/artifactory/resources/build.rb', line 112 attribute :build_retention, {} |
#diff(previous_build_number) ⇒ Hash<String, Hash>
Compare a build artifacts/dependencies/environment with an older build to see what has changed (new artifacts added, old dependencies deleted etc).
131 132 133 134 |
# File 'lib/artifactory/resources/build.rb', line 131 def diff(previous_build_number) endpoint = api_path + "?" "diff=#{url_safe(previous_build_number)}" client.get(endpoint, {}) end |
#duration_millis ⇒ Object
Return this object’s duration_millis
106 |
# File 'lib/artifactory/resources/build.rb', line 106 attribute :duration_millis |
#duration_millis=(value) ⇒ Object
Set this object’s duration_millis
106 |
# File 'lib/artifactory/resources/build.rb', line 106 attribute :duration_millis |
#duration_millis? ⇒ Boolean
Determines if the duration_millis
value exists and is truthy
106 |
# File 'lib/artifactory/resources/build.rb', line 106 attribute :duration_millis |
#governance ⇒ Object
Return this object’s governance
114 |
# File 'lib/artifactory/resources/build.rb', line 114 attribute :governance |
#governance=(value) ⇒ Object
Set this object’s governance
114 |
# File 'lib/artifactory/resources/build.rb', line 114 attribute :governance |
#governance? ⇒ Boolean
Determines if the governance
value exists and is truthy
114 |
# File 'lib/artifactory/resources/build.rb', line 114 attribute :governance |
#license_control ⇒ Object
Return this object’s license_control
111 |
# File 'lib/artifactory/resources/build.rb', line 111 attribute :license_control, {} |
#license_control=(value) ⇒ Object
Set this object’s license_control
111 |
# File 'lib/artifactory/resources/build.rb', line 111 attribute :license_control, {} |
#license_control? ⇒ Boolean
Determines if the license_control
value exists and is truthy
111 |
# File 'lib/artifactory/resources/build.rb', line 111 attribute :license_control, {} |
#modules ⇒ Object
Return this object’s modules
113 |
# File 'lib/artifactory/resources/build.rb', line 113 attribute :modules, [] |
#modules=(value) ⇒ Object
Set this object’s modules
113 |
# File 'lib/artifactory/resources/build.rb', line 113 attribute :modules, [] |
#modules? ⇒ Boolean
Determines if the modules
value exists and is truthy
113 |
# File 'lib/artifactory/resources/build.rb', line 113 attribute :modules, [] |
#name ⇒ Object
Return this object’s name
100 |
# File 'lib/artifactory/resources/build.rb', line 100 attribute :name, -> { raise "Build component missing!" } |
#name=(value) ⇒ Object
Set this object’s name
100 |
# File 'lib/artifactory/resources/build.rb', line 100 attribute :name, -> { raise "Build component missing!" } |
#name? ⇒ Boolean
Determines if the name
value exists and is truthy
100 |
# File 'lib/artifactory/resources/build.rb', line 100 attribute :name, -> { raise "Build component missing!" } |
#number ⇒ Object
Return this object’s number
101 |
# File 'lib/artifactory/resources/build.rb', line 101 attribute :number, -> { raise "Build number missing!" } |
#number=(value) ⇒ Object
Set this object’s number
101 |
# File 'lib/artifactory/resources/build.rb', line 101 attribute :number, -> { raise "Build number missing!" } |
#number? ⇒ Boolean
Determines if the number
value exists and is truthy
101 |
# File 'lib/artifactory/resources/build.rb', line 101 attribute :number, -> { raise "Build number missing!" } |
#promote(target_repo, options = {}) ⇒ Hash
Move a build’s artifacts to a new repository optionally moving or copying the build’s dependencies to the target repository and setting properties on promoted artifacts.
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/artifactory/resources/build.rb', line 177 def promote(target_repo, = {}) request_body = {}.tap do |body| body[:status] = [:status] || "promoted" body[:comment] = [:comment] || "" body[:ciUser] = [:user] || Artifactory.username body[:dryRun] = [:dry_run] || false body[:targetRepo] = target_repo body[:copy] = [:copy] || false body[:artifacts] = true # always move/copy the build's artifacts body[:dependencies] = [:dependencies] || false body[:scopes] = [:scopes] || [] body[:properties] = [:properties] || {} body[:failFast] = [:fail_fast] || true end endpoint = "/api/build/promote/#{url_safe(name)}/#{url_safe(number)}" client.post(endpoint, JSON.fast_generate(request_body), "Content-Type" => "application/json") end |
#properties ⇒ Object
Return this object’s properties
98 |
# File 'lib/artifactory/resources/build.rb', line 98 attribute :properties, {} |
#properties=(value) ⇒ Object
Set this object’s properties
98 |
# File 'lib/artifactory/resources/build.rb', line 98 attribute :properties, {} |
#properties? ⇒ Boolean
Determines if the properties
value exists and is truthy
98 |
# File 'lib/artifactory/resources/build.rb', line 98 attribute :properties, {} |
#save ⇒ Boolean
Creates data about a build.
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/artifactory/resources/build.rb', line 202 def save raise Error::InvalidBuildType.new(type) unless BUILD_TYPES.include?(type) file = Tempfile.new("build.json") file.write(to_json) file.rewind client.put("/api/build", file, "Content-Type" => "application/json") true ensure if file file.close file.unlink end end |
#started ⇒ Object
Return this object’s started
105 |
# File 'lib/artifactory/resources/build.rb', line 105 attribute :started, Time.now.utc.iso8601(3) |
#started=(value) ⇒ Object
Set this object’s started
105 |
# File 'lib/artifactory/resources/build.rb', line 105 attribute :started, Time.now.utc.iso8601(3) |
#started? ⇒ Boolean
Determines if the started
value exists and is truthy
105 |
# File 'lib/artifactory/resources/build.rb', line 105 attribute :started, Time.now.utc.iso8601(3) |
#statuses ⇒ Object
Return this object’s statuses
115 |
# File 'lib/artifactory/resources/build.rb', line 115 attribute :statuses, [] |
#statuses=(value) ⇒ Object
Set this object’s statuses
115 |
# File 'lib/artifactory/resources/build.rb', line 115 attribute :statuses, [] |
#statuses? ⇒ Boolean
Determines if the statuses
value exists and is truthy
115 |
# File 'lib/artifactory/resources/build.rb', line 115 attribute :statuses, [] |
#type ⇒ Object
Return this object’s type
102 |
# File 'lib/artifactory/resources/build.rb', line 102 attribute :type, "GENERIC" |
#type=(value) ⇒ Object
Set this object’s type
102 |
# File 'lib/artifactory/resources/build.rb', line 102 attribute :type, "GENERIC" |
#type? ⇒ Boolean
Determines if the type
value exists and is truthy
102 |
# File 'lib/artifactory/resources/build.rb', line 102 attribute :type, "GENERIC" |
#url ⇒ Object
Return this object’s url
108 |
# File 'lib/artifactory/resources/build.rb', line 108 attribute :url |
#url=(value) ⇒ Object
Set this object’s url
108 |
# File 'lib/artifactory/resources/build.rb', line 108 attribute :url |
#url? ⇒ Boolean
Determines if the url
value exists and is truthy
108 |
# File 'lib/artifactory/resources/build.rb', line 108 attribute :url |
#vcs_revision ⇒ Object
Return this object’s vcs_revision
109 |
# File 'lib/artifactory/resources/build.rb', line 109 attribute :vcs_revision |
#vcs_revision=(value) ⇒ Object
Set this object’s vcs_revision
109 |
# File 'lib/artifactory/resources/build.rb', line 109 attribute :vcs_revision |
#vcs_revision? ⇒ Boolean
Determines if the vcs_revision
value exists and is truthy
109 |
# File 'lib/artifactory/resources/build.rb', line 109 attribute :vcs_revision |
#vcs_url ⇒ Object
Return this object’s vcs_url
110 |
# File 'lib/artifactory/resources/build.rb', line 110 attribute :vcs_url |
#vcs_url=(value) ⇒ Object
Set this object’s vcs_url
110 |
# File 'lib/artifactory/resources/build.rb', line 110 attribute :vcs_url |
#vcs_url? ⇒ Boolean
Determines if the vcs_url
value exists and is truthy
110 |
# File 'lib/artifactory/resources/build.rb', line 110 attribute :vcs_url |
#version ⇒ Object
Return this object’s version
99 |
# File 'lib/artifactory/resources/build.rb', line 99 attribute :version, BUILD_SCHEMA_VERSION |
#version=(value) ⇒ Object
Set this object’s version
99 |
# File 'lib/artifactory/resources/build.rb', line 99 attribute :version, BUILD_SCHEMA_VERSION |
#version? ⇒ Boolean
Determines if the version
value exists and is truthy
99 |
# File 'lib/artifactory/resources/build.rb', line 99 attribute :version, BUILD_SCHEMA_VERSION |