Merge commit '0e3ea698c71c1d697dfeab5c9a2d6010a1ee4d9e'

This commit is contained in:
Dan Hawkins 2021-12-22 23:35:11 +00:00
commit aad347e58b
2 changed files with 143 additions and 86 deletions

View file

@ -24,13 +24,15 @@ class ProductInfo extends GISJsonSerialised {
private String productname
private String subcomponentname
private String variant
private String uniqueid
ProductInfo(script, productname = "", subcomponentname = "", variant = "") {
ProductInfo(script, String productname = '', String subcomponentname = '', String variant = '') {
super(script)
this.format = '0.1'
this.productname = productname
this.subcomponentname = subcomponentname
this.variant = variant
this.uniqueid = UUID.randomUUID().toString()
}
void set(String productname, String subcomponentname, String variant = '') {
@ -76,13 +78,15 @@ class ProductInfo extends GISJsonSerialised {
this.productname = otherinfo.productname
this.subcomponentname = otherinfo.subcomponentname
this.variant = otherinfo.variant
this.uniqueid = otherinfo.uniqueid
}
void deserialiseJson(rawmeta) {
//format = rawmeta['format']
productname = rawmeta['productname']
subcomponentname = rawmeta['subcomponentname']
variant = rawmeta['variant'] ?: ""
variant = rawmeta['variant'] ?: ''
uniqueid = rawmeta['uniqueid'] ?: uniqueid
}
LinkedHashMap serialisationdata() {
@ -91,6 +95,7 @@ class ProductInfo extends GISJsonSerialised {
'productname' : productname,
'subcomponentname' : subcomponentname,
'variant' : variant,
'uniqueid': uniqueid,
]
return data
}
@ -104,7 +109,7 @@ class GitInfo extends GISJsonSerialised {
private String remoteurl
private String remoteinfo
GitInfo(script, sourcepath = "", sourcerevision = "", gitrevision = "", remoteurl = "", remoteinfo = "") {
GitInfo(script, sourcepath = '', sourcerevision = '', gitrevision = '', remoteurl = '', remoteinfo = '') {
super(script)
this.format = '0.1'
this.sourcepath = sourcepath
@ -204,7 +209,7 @@ class JenkinsBuildInfo extends GISJsonSerialised {
private ArrayList<JenkinsBuildParameter> parameters
private boolean isfullbuild
JenkinsBuildInfo(script, String buildjobname = "", int buildnumber = 0, String buildmachine = "", String builddate = "", boolean isfullbuild = true) {
JenkinsBuildInfo(script, String buildjobname = '', int buildnumber = 0, String buildmachine = '', String builddate = '', boolean isfullbuild = true) {
super(script)
this.format = '0.1'
this.buildjobname = buildjobname
@ -370,7 +375,7 @@ class ReleaseInfo extends GISJsonSerialised {
private ArrayList<String> releaseitems
private boolean released
ReleaseInfo(script, String releaserepoURL = "", boolean released = false) {
ReleaseInfo(script, String releaserepoURL = '', boolean released = false) {
super(script)
this.format = '0.1'
this.releaserepoURL = releaserepoURL
@ -378,7 +383,7 @@ class ReleaseInfo extends GISJsonSerialised {
this.released = released
}
void set(String releaserepoURL = "") {
void set(String releaserepoURL = '') {
this.releaserepoURL = releaserepoURL
}
@ -426,7 +431,7 @@ class ConfigurationInfo extends GISJsonSerialised {
private String configurationversion
private String configurationSHA
ConfigurationInfo(script, configurationname = "", configurationURL = "", configurationversion = "", configurationSHA = "") {
ConfigurationInfo(script, configurationname = '', configurationURL = '', configurationversion = '', configurationSHA = '') {
super(script)
this.configurationname = configurationname
this.configurationURL = configurationURL
@ -456,7 +461,7 @@ class ChecksumPair extends GISJsonSerialised {
private String filepath
private String sum
ChecksumPair(script, String filepath = "", String sum = "") {
ChecksumPair(script, String filepath = '', String sum = '') {
super(script)
this.filepath = filepath
this.sum = sum
@ -481,7 +486,7 @@ class ChecksumSet extends GISJsonSerialised {
private String artifactpath
private ArrayList<ChecksumPair> checksumpairs
ChecksumSet(script, artifactpath = "") {
ChecksumSet(script, artifactpath = '') {
super(script)
this.format = '0.1'
this.artifactpath = artifactpath
@ -566,7 +571,7 @@ class PublishableInfo extends GISJsonSerialised {
private String format
private String filepath
PublishableInfo(script, String filepath = "") {
PublishableInfo(script, String filepath = '') {
super(script)
this.format = '0.1'
this.filepath = filepath
@ -592,12 +597,7 @@ class MetaInfo extends GISJsonSerialised {
private static String METAARTIFACTS = "${METAFOLDERNAME}/**"
private static String format = '0.2'
interface IRelatedMetaInfo {
abstract void deserialiseJson(rawmeta)
abstract LinkedHashMap serialisationdata()
}
abstract class RelatedMetaInfo extends GISJsonSerialised implements IRelatedMetaInfo {
abstract class RelatedMetaInfo extends GISJsonSerialised {
String format
RelatedMetaInfo(script, format) {
@ -607,20 +607,24 @@ class MetaInfo extends GISJsonSerialised {
abstract void deserialiseJson(rawmeta)
abstract LinkedHashMap serialisationdata()
abstract String getrelatedid()
}
class RelatedMetaInfo_v0_1 extends RelatedMetaInfo {
private MetaInfo meta
private String offsetpath
private String uniqueid
RelatedMetaInfo_v0_1(script, offsetpath = "", MetaInfo meta = null) {
RelatedMetaInfo_v0_1(script, String offsetpath = '', MetaInfo meta = null, String uniqueid = UUID.randomUUID().toString()) {
super(script, '0.1')
this.offsetpath = offsetpath
this.uniqueid = uniqueid
this.meta = meta
}
void deserialiseJson(rawmeta) {
offsetpath = rawmeta['offsetpath']
uniqueid = rawmeta['uniqueid'] ?: uniqueid
meta = new MetaInfo(script)
meta.deserialiseJson(rawmeta['meta'])
}
@ -629,34 +633,47 @@ class MetaInfo extends GISJsonSerialised {
def data = [
'format' : format,
'offsetpath' : offsetpath,
'uniqueid' : uniqueid,
'meta' : meta.serialisationdata(),
]
return data
}
String getrelatedid() {
return uniqueid
}
}
class RelatedMetaInfo_v0_2 extends RelatedMetaInfo {
private String importpath
private String offsetpath
private String uniqueid
RelatedMetaInfo_v0_2(script, importpath = "", offsetpath = "") {
RelatedMetaInfo_v0_2(script, String importpath = '', String offsetpath = '', String uniqueid = UUID.randomUUID().toString()) {
super(script, '0.2')
this.importpath = importpath
this.offsetpath = offsetpath
this.uniqueid = uniqueid
}
void deserialiseJson(rawmeta) {
//format = rawmeta['format']
offsetpath = rawmeta['offsetpath']
uniqueid = rawmeta['uniqueid']
}
LinkedHashMap serialisationdata() {
def data = [
'format' : format,
'offsetpath' : offsetpath,
'uniqueid' : uniqueid
]
return data
}
String getrelatedid() {
return uniqueid
}
}
private ProductInfo productinfo
@ -826,7 +843,7 @@ class MetaInfo extends GISJsonSerialised {
script.echo("Deserialising meta at file: ${importedmetafile} (destpath: ${destpath})")
mi.deserialiseJson(importedmetafile)
RelatedMetaInfo rmi = new RelatedMetaInfo_v0_2(script, importedmetafile, adjustedpath)
RelatedMetaInfo rmi = new RelatedMetaInfo_v0_2(script, importedmetafile, adjustedpath, mi.productinfo.uniqueid)
if (appendtoparentmeta) {
associatedmeta.add(rmi)
}
@ -920,14 +937,57 @@ class MetaInfo extends GISJsonSerialised {
}
}
def openchildmeta(String gatheredpath, String gatheredmetapath, RelatedMetaInfo relatedmetainfo) {
class IterationInfo {
private ArrayList<CollectedMeta> metacollection
private Map<String, CollectedMeta> metamap
private String comment
private int level
private String gatheredpath
private String gatheredmetapath
private boolean limiteddepth
private int maxdepth
IterationInfo(ArrayList<CollectedMeta> metacollection,
Map<String, CollectedMeta> metamap,
String comment = '',
int level = 0,
String gatheredpath = '',
String gatheredmetapath = '',
boolean limiteddepth = false,
int maxdepth = 0) {
this.metacollection = metacollection
this.metamap = metamap
this.comment = comment
this.level = level
this.gatheredpath = gatheredpath
this.gatheredmetapath = gatheredmetapath
this.limiteddepth = limiteddepth
this.maxdepth = maxdepth
}
String show() {
return "Iteration:\nLevel: ${level}\nGathered path: ${gatheredpath}\nGathered meta path: ${gatheredmetapath}\nLimited depth: ${limiteddepth}\nMax depth: ${maxdepth}"
}
void add(CollectedMeta item) {
metacollection.add(item)
metamap.put(item.metainfo.productinfo.uniqueid, item)
}
}
def openchildmeta(IterationInfo ii, RelatedMetaInfo relatedmetainfo) {
def MetaInfo mi = new MetaInfo(script)
def String nextgatheredpath = (gatheredpath == '' ? relatedmetainfo.offsetpath : "${gatheredpath}/${relatedmetainfo.offsetpath}")
def String nextgatheredmetapath = (gatheredmetapath == '' ? "${relatedmetainfo.offsetpath}/${METAFOLDERNAME}" : "${gatheredmetapath}/${relatedmetainfo.offsetpath}")
def String nextgatheredpath = (ii.gatheredpath == '' ? relatedmetainfo.offsetpath : "${ii.gatheredpath}/${relatedmetainfo.offsetpath}")
def String nextgatheredmetapath = (ii.gatheredmetapath == '' ? "${relatedmetainfo.offsetpath}/${METAFOLDERNAME}" : "${ii.gatheredmetapath}/${relatedmetainfo.offsetpath}")
def importedmetafile = "${nextgatheredmetapath}/${METAFILENAME}"
def boolean imported
if (script.fileExists(importedmetafile)) {
// If this has already been read in from a file
if (relatedmetainfo.getrelatedid() in ii.metamap) {
script.echo("Already read in meta associated with uniqueid: ${relatedmetainfo.getrelatedid()} - Using it")
mi = ii.metamap[relatedmetainfo.getrelatedid()].metainfo
imported = true
} else if (script.fileExists(importedmetafile)) {
mi.deserialiseJson(importedmetafile)
imported = true
} else {
@ -944,92 +1004,89 @@ class MetaInfo extends GISJsonSerialised {
return childmetainfo
}
def walkrelated_v0_1(ArrayList<CollectedMeta> metacollection,
String comment = '',
int level = 0,
String gatheredpath = '',
String gatheredmetapath = '',
boolean limiteddepth = false,
int maxdepth = 0) {
script.echo("walkrelated_v0_1 Iteration:\nLevel: ${level}\nGathered path: ${gatheredpath}\nGathered meta path: ${gatheredmetapath}\nLimited depth: ${limiteddepth}\nMax depth: ${maxdepth}")
def results = [
'metacollection' : metacollection,
'comment': comment
]
if (!limiteddepth || maxdepth > 0) {
results.metacollection.add(new CollectedMeta(this, gatheredpath, gatheredmetapath))
results.comment += "${level} ".padRight(level * 4) + globalreleasetag() + '\n'
def walkrelated_v0_1(IterationInfo ii) {
script.echo("Walk related v0.1: ${ii.show()}")
if (!ii.limiteddepth || ii.maxdepth > 0) {
ii.add(new CollectedMeta(this, ii.gatheredpath, ii.gatheredmetapath))
ii.comment += "${ii.level} ".padRight(ii.level * 4) + globalreleasetag() + '\n'
for (relatedmetainfo in associatedmeta) {
if (!relatedmetainfo.format || relatedmetainfo.format == '0.1') {
def MetaInfo othermeta = relatedmetainfo.meta
def String nextgatheredpath = (gatheredpath == '' ? relatedmetainfo.offsetpath : "${gatheredpath}/${relatedmetainfo.offsetpath}")
def String nextgatheredmetapath = (gatheredmetapath == '' ? relatedmetainfo.offsetpath : "${gatheredmetapath}/${relatedmetainfo.offsetpath}")
results = othermeta.walkrelated_v0_1(results.metacollection,
results.comment,
level + 1,
nextgatheredpath,
nextgatheredmetapath,
limiteddepth,
maxdepth - 1)
def String nextgatheredpath = (ii.gatheredpath == '' ? relatedmetainfo.offsetpath : "${ii.gatheredpath}/${relatedmetainfo.offsetpath}")
def String nextgatheredmetapath = (ii.gatheredmetapath == '' ? relatedmetainfo.offsetpath : "${ii.gatheredmetapath}/${relatedmetainfo.offsetpath}")
def nextii = new IterationInfo(ii.metacollection,
ii.metamap,
ii.comment,
ii.level + 1,
nextgatheredpath,
nextgatheredmetapath,
ii.limiteddepth,
ii.maxdepth - 1)
def results = othermeta.walkrelated_v0_1(nextii)
ii.metacollection = results.metacollection
ii.metamap = results.metamap
ii.comment = results.comment
} else {
script.error("There is non v0.1 format related meta info under v0.1 related meta info")
}
}
}
return [ 'metacollection' : results.metacollection, 'comment': results.comment ]
return [ 'metacollection' : ii.metacollection, 'metamap' : ii.metamap, 'comment': ii.comment ]
}
def walkrelated(ArrayList<CollectedMeta> metacollection,
String comment = '',
int level = 0,
String gatheredpath = '',
String gatheredmetapath = '',
boolean limiteddepth = false,
int maxdepth = 0) {
script.echo("walkrelated Iteration:\nLevel: ${level}\nGathered path: ${gatheredpath}\nGathered meta path: ${gatheredmetapath}\nLimited depth: ${limiteddepth}\nMax depth: ${maxdepth}")
def results = [
'metacollection' : metacollection,
'comment': comment
]
if (!limiteddepth || maxdepth > 0) {
results.metacollection.add(new CollectedMeta(this, gatheredpath, gatheredmetapath))
results.comment += "${level} ".padRight(level * 4) + globalreleasetag() + '\n'
def walkrelated(IterationInfo ii) {
script.echo("Walk related: ${ii.show()}")
if (!ii.limiteddepth || ii.maxdepth > 0) {
ii.add(new CollectedMeta(this, ii.gatheredpath, ii.gatheredmetapath))
ii.comment += "${ii.level} ".padRight(ii.level * 4) + globalreleasetag() + '\n'
for (relatedmetainfo in associatedmeta) {
script.echo("Related meta info: ${relatedmetainfo.offsetpath} format: ${relatedmetainfo.format}")
if (relatedmetainfo.format == '0.2') {
def childmetainfo = openchildmeta(gatheredpath, gatheredmetapath, relatedmetainfo)
def childmetainfo = openchildmeta(ii, relatedmetainfo)
if (childmetainfo.imported) {
results = childmetainfo.childmeta.walkrelated(results.metacollection,
results.comment,
level + 1,
childmetainfo.nextgatheredpath,
childmetainfo.nextgatheredmetapath,
limiteddepth,
maxdepth - 1)
def nextii = new IterationInfo(ii.metacollection,
ii.metamap,
ii.comment,
ii.level + 1,
childmetainfo.nextgatheredpath,
childmetainfo.nextgatheredmetapath,
ii.limiteddepth,
ii.maxdepth - 1)
def results = childmetainfo.childmeta.walkrelated(nextii)
ii.metacollection = results.metacollection
ii.metamap = results.metamap
ii.comment = results.comment
}
} else if (!relatedmetainfo.format || relatedmetainfo.format == '0.1') {
def MetaInfo othermeta = relatedmetainfo.meta
results = othermeta.walkrelated_v0_1(results.metacollection,
results.comment,
level + 1,
gatheredpath,
gatheredmetapath,
limiteddepth,
maxdepth - 1)
def nextii = new IterationInfo(ii.metacollection,
ii.metamap,
ii.comment,
ii.level + 1,
ii.gatheredpath,
ii.gatheredmetapath,
ii.limiteddepth,
ii.maxdepth - 1)
def results = othermeta.walkrelated_v0_1(nextii)
ii.metacollection = results.metacollection
ii.metamap = results.metamap
ii.comment = results.comment
}
}
}
return [ 'metacollection' : results.metacollection, 'comment': results.comment ]
return [ 'metacollection' : ii.metacollection, 'metamap' : ii.metamap, 'comment': ii.comment ]
}
def allrelatedmeta(String metapath = '') {
ArrayList<CollectedMeta> metacollection = new ArrayList<CollectedMeta>()
return walkrelated(metacollection, '', 0, '', metapath)
def ArrayList<CollectedMeta> metacollection = new ArrayList<CollectedMeta>()
def Map<String, CollectedMeta> metamap = new LinkedHashMap<String, CollectedMeta>()
return walkrelated(new IterationInfo(metacollection, metamap, '', 0, '', metapath))
}
ArrayList<CollectedMeta> releasewalker(int maxdepth, String startpath = '', String startmetapath = '') {
def ArrayList<CollectedMeta> metacollection = new ArrayList<CollectedMeta>()
def results = walkrelated(metacollection, 'meta', 0, startpath, startmetapath, true, maxdepth)
def Map<String, CollectedMeta> metamap = new LinkedHashMap<String, CollectedMeta>()
def results = walkrelated(new IterationInfo(metacollection, metamap, 'meta', 0, startpath, startmetapath, true, maxdepth))
return results.metacollection
}
@ -1106,13 +1163,13 @@ MetaInfo metareset(script) {
return mi
}
MetaInfo metafromfolder(String folder = "") {
MetaInfo metafromfolder(String folder = '') {
MetaInfo buildmeta = new MetaInfo(this)
buildmeta.deserialiseJson("${folder}/${MetaInfo.metafilepath()}")
return buildmeta
}
MetaInfo metafromfolderSlurper(String folder = "") {
MetaInfo metafromfolderSlurper(String folder = '') {
MetaInfo buildmeta = new MetaInfo(this)
buildmeta.deserialiseJsonSlurper("${folder}/${MetaInfo.metafilepath()}")
return buildmeta

View file

@ -195,8 +195,8 @@ def docheckout(String gitURL, String revision, int cloneDepth, String reporootpa
[name: revision]
],
extensions: [
[$class: 'GitLFSPull'],
[$class: 'CleanBeforeCheckout'],
[$class: 'GitLFSPull',timeout: 25],
[$class: 'CleanBeforeCheckout',timeout: 20],
[$class: 'CloneOption', depth: cloneDepth, noTags: false, reference: reporootpath, shallow: shallowClone, timeout: 120],
[$class: 'CheckoutOption', timeout: 120],
[$class: 'RelativeTargetDirectory', relativeTargetDir: targetDir],