lib/cicd/builder/mixlib/repo/S3.rb in cicd-builder-0.9.52 vs lib/cicd/builder/mixlib/repo/S3.rb in cicd-builder-0.9.57
- old
+ new
@@ -190,11 +190,11 @@
raise CiCd::Builder::Errors::Internal.new sprintf('Internal logic error! %s::%d', __FILE__,__LINE__) if varianth.nil?
# Add the new build if we don't have it
unless varianth['builds'].map { |b| b['build_name'] }.include?(@vars[:build_nmn])
# noinspection RubyStringKeysInHashInspection
filing = _createFiling(json, {
- 'drawer' => @vars[:build_nam],
+ 'drawer' => (@vars[:build_mvn] ? "#{@vars[:build_nam]}/#{@vars[:build_mvn]}" : @vars[:build_nam]),
'build_name' => @vars[:build_nmn],
'build_number' => @vars[:build_num],
'release' => @vars[:release],
'artifacts' => @vars[:artifacts],
'build_ext' => @vars[:build_ext],
@@ -807,30 +807,32 @@
s3 = getS3()
list.each do |obj|
@logger.debug "Inspect #{obj[:key]}"
delete = false
- unless obj[:key].match(%r'#{key}$')
+ unless obj[:key].match(%r'#{key}$') # It is not INVENTORY.json
item = obj[:key].dup
- if item.match(%r'^#{@vars[:product]}')
+ if item.match(%r'^#{@vars[:product]}') # Starts as ChefRepo/ for example
item.gsub!(%r'^#{@vars[:product]}/', '')
- matches = item.match(%r'^([^/]+)/')
+ matches = item.match(%r'^([^/]+)/') # Next part should be variant i.e. SNAPSHOT
if matches
variant = matches[1]
if variants.has_key?(variant)
varianth = variants[variant]
item.gsub!(%r'^#{variant}/', '')
- matches = item.match(%r'^([^/]+)/')
- if matches
- drawer = matches[1]
+ #matches = item.match(%r'^([^/]+)/') # Match the drawer name ...
+ drawer,item = File.split(item) # What remains is drawer name and artifact name
+ #if matches
+ if drawer and item
+ # drawer = matches[1]
builds = varianth['builds'].select{ |bld|
bld['drawer'].eql?(drawer)
}
if builds.size > 0
- item.gsub!(%r'^#{drawer}/', '')
+ # item.gsub!(%r'^#{drawer}/', '')
- if item.match(%r'^#{drawer}')
+ if item.match(%r'^#{drawer.match('/') ? drawer.split('/')[0] : drawer}') # Artifact names which start with the drawer name ...
name = item.gsub(%r'\.(MANIFEST\.json|tar\.[bg]z2?|tgz|tbz2?|checksum)$', '')
ver = _getMatches(@vars, name, :version)
rel = _getMatches(@vars, name, :release)
bra = _getMatches(@vars, name, :branch)
var = _getMatches(@vars, name, :variant)
@@ -913,28 +915,30 @@
else
list = pullRepo()
fileroom = {}
list.each do |obj|
- unless obj[:key].match(%r'#{key}$')
+ unless obj[:key].match(%r'#{key}$') # INVENTORY.json ?
item = obj[:key].dup
- if item.match(%r'^#{@vars[:product]}')
+ if item.match(%r'^#{@vars[:product]}') # ChefRepo/....
item.gsub!(%r'^#{@vars[:product]}/', '')
- matches = item.match(%r'^([^/]+)/')
+ matches = item.match(%r'^([^/]+)/') # SNAPSHOT/...
if matches
variant = matches[1]
fileroom[variant] ||= {}
cabinet = fileroom[variant]
item.gsub!(%r'^#{variant}/', '')
- matches = item.match(%r'^([^/]+)/')
- if matches
- drawer = matches[1]
- item.gsub!(%r'^#{drawer}/', '')
+ #matches = item.match(%r'^([^/]+)/') # Match the drawer name ...
+ drawer,item = File.split(item) # What remains is drawer name and artifact name
+ #if matches
+ if drawer and item
+ # drawer = matches[1]
+ # item.gsub!(%r'^#{drawer}/', '')
cabinet[drawer] ||= {}
tray = cabinet[drawer]
# tray['builds'] ||= {}
- if item.match(%r'^#{drawer}')
+ if item.match(%r'^#{drawer.match('/') ? drawer.split('/')[0] : drawer}') # Artifacts which start with the drawer name
name = item.gsub(%r'\.(MANIFEST\.json|tar\.[bg]z2?|tgz|tbz2?|checksum)$', '')
ext = item.gsub(%r'\.(tar\.[bg]z2?)$', '$1')
ext = 'tar.bz2' if ext == item
ver = _getMatches(@vars, name, :version)
rel = _getMatches(@vars, name, :release)
\ No newline at end of file