lib/cicd/builder/mixlib/repo/S3.rb in cicd-builder-0.9.48 vs lib/cicd/builder/mixlib/repo/S3.rb in cicd-builder-0.9.50
- old
+ new
@@ -337,13 +337,13 @@
}
build_ver
end
# ---------------------------------------------------------------------------------------------------------------
- def pullInventory()
+ def pullInventory(product=nil)
json = nil
- key, s3_obj = checkForInventory()
+ key, s3_obj = checkForInventory(product)
# If the inventory has started then add to it else create a new one
if s3_obj.nil?
# Start a new inventory
over = true
else
@@ -368,12 +368,15 @@
end
return key, json, over
end
# ---------------------------------------------------------------------------------------------------------------
- def checkForInventory
- key = "#{@vars[:project_name]}/INVENTORY.json"
+ def checkForInventory(product=nil)
+ if product.nil?
+ product = @vars[:project_name]
+ end
+ key = "#{product}/INVENTORY.json"
s3_obj = maybeS3Object(key)
return key, s3_obj
end
# ---------------------------------------------------------------------------------------------------------------
@@ -404,11 +407,11 @@
h
end
# ---------------------------------------------------------------------------------------------------------------
def uploadBuildArtifacts()
- @logger.step __method__.to_s
+ @logger.step CLASS+'::'+__method__.to_s
if @vars.has_key?(:build_dir) and @vars.has_key?(:build_pkg)
artifacts = @vars[:artifacts] rescue []
key = getKey()
if File.exists?(@vars[:build_pkg])
@@ -621,33 +624,11 @@
if varianth['latest'] and varianth['latest'].is_a?(Hash)
puts "Variant: #{variant}"
puts "\t#{varianth['builds'].size} builds"
puts "\t#{varianth['branches'].size} branches:\n#{varianth['branches'].ai}"
# puts "\t#{varianth['versions'].size} versions:\n#{varianth['versions'].ai}"
- versions = {}
- releases = {}
- versrels = {}
- bmin = -1
- bmax = -1
- varianth['builds'].each do |bld|
- releases[bld['release']] ||= 0
- releases[bld['release']] += 1
- unless bld['build_number'].nil?
- bnum = bld['build_number'].to_i
- if bmin < 0 or bnum < bmin
- bmin = bnum
- end
- if bnum > bmax
- bmax = bnum
- end
- end
- ver = _getMatches(@vars, bld['build_name'], :version)
- versions[ver] ||= 0
- versions[ver] += 1
- versrels["#{ver}-#{bld['release']}"] ||= 0
- versrels["#{ver}-#{bld['release']}"] += 1
- end
+ bmax, bmin, releases, versions, versrels = getVariantVersionsAndReleases(varianth)
puts "\t#{versions.size} versions:\n#{versions.ai}"
puts "\t#{releases.size} releases:\n#{releases.ai}"
puts "\t#{versrels.size} version-releases:\n#{versrels.ai}"
puts "\tBuilds: Min: #{bmin}, Max: #{bmax}"
else
@@ -676,10 +657,38 @@
end
@vars[:return_code]
end
# ---------------------------------------------------------------------------------------------------------------
+ def getVariantVersionsAndReleases(varianth)
+ versions = {}
+ releases = {}
+ versrels = {}
+ bmin = -1
+ bmax = -1
+ varianth['builds'].each do |bld|
+ releases[bld['release']] ||= 0
+ releases[bld['release']] += 1
+ unless bld['build_number'].nil?
+ bnum = bld['build_number'].to_i
+ if bmin < 0 or bnum < bmin
+ bmin = bnum
+ end
+ if bnum > bmax
+ bmax = bnum
+ end
+ end
+ ver = _getMatches(@vars, bld['build_name'], :version)
+ versions[ver] ||= 0
+ versions[ver] += 1
+ versrels["#{ver}-#{bld['release']}"] ||= 0
+ versrels["#{ver}-#{bld['release']}"] += 1
+ end
+ return bmax, bmin, releases, versions, versrels
+ end
+
+ # ---------------------------------------------------------------------------------------------------------------
def pruneInventory()
@logger.step __method__.to_s
# Read and parse in JSON
key, json, over = pullInventory()
if json.nil?
@@ -1058,10 +1067,10 @@
}
# noinspection RubyHashKeysTypesInspection
varianth['branches'] = Hash[branches.map.with_index.to_a].keys
end
- private :_update, :checkForInventory, :pullInventory, :_update, :_updateBranches, :_updateLatest, :_updateVersions
+ protected :_update, :_update, :_updateBranches, :_updateLatest, :_updateVersions
end
end
end
end
\ No newline at end of file