diff --git a/artifacts/metaexport.groovy b/artifacts/metaexport.groovy index 8e5e56e..a40e9a8 100644 --- a/artifacts/metaexport.groovy +++ b/artifacts/metaexport.groovy @@ -4,7 +4,7 @@ def combineSubjobArtifacts(meta, importer, subJobs) { for (subJob in subJobs) { def subJobObject = subJob[0] if (subJobObject != null) { - def subJobName = subJobObject.getProjectName() + def subJobName = subJobObject.getFullProjectName() def subJobNumber = subJobObject.getNumber() def destFolder = subJob[1] def boolean incrementversionnumber = subJob[2] diff --git a/import/importer.groovy b/import/importer.groovy index 8bb565a..4948cad 100644 --- a/import/importer.groovy +++ b/import/importer.groovy @@ -20,6 +20,8 @@ class ImportOptions { String m_repo String m_revision + + boolean m_showdetails ImportOptions(script, String sourceselect = 'Jenkins job artifact', @@ -31,7 +33,8 @@ class ImportOptions { boolean flatten = false, boolean includemetainfilter = true, boolean clean = true, - appendtoparentmeta = true) { + appendtoparentmeta = true, + showdetails = false) { m_script = script m_sourceselect = sourceselect.trim() m_incrementversionnumber = incrementversionnumber @@ -43,6 +46,25 @@ class ImportOptions { m_includemetainfilter = includemetainfilter m_clean = clean m_appendtoparentmeta = appendtoparentmeta + m_showdetails = showdetails + } + + String show() { + return """m_incrementversionnumber: ${m_incrementversionnumber} + m_filter: ${m_filter} + m_excludes: ${m_excludes} + m_fingerprint: ${m_fingerprint} + m_nested: ${m_nested} + m_flatten: ${m_flatten} + m_includemetainfilter: ${m_includemetainfilter} + m_clean: ${m_clean} + m_appendtoparentmeta: ${m_appendtoparentmeta} + m_sourceselect: ${m_sourceselect} + m_jobname: ${m_jobname} + m_buildnumberorselector: ${m_buildnumberorselector} + m_repo: ${m_repo} + m_revision: ${m_revision} + """ } void setsourceselect(String sourceselect) { @@ -56,7 +78,7 @@ class ImportOptions { m_sourceselect = sourceselect break default: - error("Unknown type of artifact source select: ${m_sourceselect}") + m_script.error("Unknown type of artifact source select: ${sourceselect}") } } @@ -96,7 +118,7 @@ class ImportOptions { m_appendtoparentmeta = appendtoparentmeta } - void jenkinsjob(String jobname, buildnumberorselector) { + void jenkinsjob(String jobname, String buildnumberorselector) { m_jobname = jobname.trim() m_buildnumberorselector = [ $class: 'ParameterizedBuildSelector', @@ -109,7 +131,7 @@ class ImportOptions { m_jobname = jobname.trim() m_buildnumberorselector = [ $class: 'ParameterizedBuildSelector', - parameterName: "${buildnumberorselector}" + parameterName: "${buildnumberorselector}" ] setsourceselect('Jenkins job artifact') } @@ -125,6 +147,10 @@ class ImportOptions { releaserepo(repo, revision) setsourceselect(sourceselect) } + + void showdetails(boolean showdetails) { + m_showdetails = showdetails + } } ImportOptions getNewImportOptions() { @@ -151,7 +177,7 @@ def conditionalClean(ImportOptions importoptions, String destpath) { } } -def artifactimportfrombuildjob(meta, importoptions, String destpath) { +def artifactimportfrombuildjob(meta, ImportOptions importoptions, String destpath) { if (importoptions.m_sourceselect != 'Jenkins job artifact') { error("Import options settings have not been set for: Jenkins job artifact") return @@ -183,7 +209,7 @@ def rewritemetafileasreleased(meta, String filepath) { meta.saveJsonSerialised(filepath) } -def hierarchyartifactimportfromrepo(meta, importoptions, String destpath) { +def hierarchyartifactimportfromrepo(meta, ImportOptions importoptions, String destpath) { if (importoptions.m_sourceselect != 'Release repository') { error("Import options settings have not been set for: Release repository") return @@ -199,12 +225,17 @@ def hierarchyartifactimportfromrepo(meta, importoptions, String destpath) { gh.gitCheckoutAlt(rooturl, rootrevision, destpath, "", 1, true, sparseitemlist) def importedmeta = meta.importrelated(importoptions.m_appendtoparentmeta, destpath, rooturl, rootrevision, gh.getGitInfo(destpath)) - - relatedimportinfo = importedmeta.getassociated() - echo "Cloning associated repos" - for(relatedmetainfo in relatedimportinfo) { - def relatedmeta = relatedmetainfo.meta - def relatedoffsetpath = relatedmetainfo.offsetpath + + echo "Getting associated metadata from path: ${destpath}" + def collectedmetalist = importedmeta.getassociated(destpath) + for(def collectedmeta in collectedmetalist) { + echo "Collection meta item: ${collectedmeta.metainfo.componentversionuniqueidentifier()} offset path: ${collectedmeta.accumulatedpath}" + } + + echo "Cloning associated repos inside path: ${destpath}" + for(def collectedmeta in collectedmetalist) { + def relatedmeta = collectedmeta.metainfo + def relatedoffsetpath = collectedmeta.accumulatedpath def cloneurl = relatedmeta.releaseinfo.releaserepoURL def clonerevision = "refs/tags/${relatedmeta.releasetag()}" def clonepath = "${destpath}/${relatedoffsetpath}" @@ -214,7 +245,7 @@ def hierarchyartifactimportfromrepo(meta, importoptions, String destpath) { gh.stripgithistory(clonepath) - def metafilepath = "${clonepath}/${relatedmeta.metafilepath()}" + def metafilepath = "${clonepath}${relatedmeta.metafilepath()}" echo "Marking related meta as released and rewriting meta file: ${metafilepath}" rewritemetafileasreleased(relatedmeta, metafilepath) } @@ -229,7 +260,7 @@ def hierarchyartifactimportfromrepo(meta, importoptions, String destpath) { return importedmeta } -def artifactimportfromrepo(meta, importoptions, String destpath) { +def artifactimportfromrepo(meta, ImportOptions importoptions, String destpath) { if (importoptions.m_sourceselect != 'Release repository') { error("Import options settings have not been set for: Release repository") return @@ -257,7 +288,10 @@ def artifactimportfromrepo(meta, importoptions, String destpath) { return importedmeta } -def artifactimport(meta, importoptions, String destpath) { +def artifactimport(meta, ImportOptions importoptions, String destpath) { + if (importoptions.m_showdetails) { + echo "Importing artifacts:\nImport options:\n${importoptions.show()}\nto: ${destpath}" + } switch (importoptions.m_sourceselect) { case 'Jenkins job artifact': case 'Jenkins job artefact': @@ -342,7 +376,13 @@ def artifactimport(meta, } // Import the artifacts of a named child component found below parent meta's hierarchy -def artifactimport(meta, parentmeta, String parentmetapath, String childproduct, String childsubcomponent, importoptions, String destinationfolder) { +def artifactimport(meta, + parentmeta, + String parentmetapath, + String childproduct, + String childsubcomponent, + ImportOptions importoptions, + String destinationfolder) { // Import from parent meta def childmeta = meta.getNewMetaObject() def childmeta2 @@ -351,7 +391,7 @@ def artifactimport(meta, parentmeta, String parentmetapath, String childproduct, def findresults = parentmeta.findAssociatedMeta(parentmetapath, childproduct, childsubcomponent) if (findresults.matchfound) { childmeta = findresults.matchedmetaitem.metainfo - if (childmeta.releaseinfo.released) { + if (importoptions.m_sourceselect == 'Release repository' || childmeta.releaseinfo.released) { importoptions.releaserepo(childmeta.releaseinfo.releaserepoURL, childmeta.releasetag()) } else { importoptions.jenkinsjob(childmeta.jenkinsbuildinfo.buildjobname, childmeta.jenkinsbuildinfo.buildnumber) diff --git a/install/installhelper.groovy b/install/installhelper.groovy index 96a8b2e..8dbf23e 100644 --- a/install/installhelper.groovy +++ b/install/installhelper.groovy @@ -23,17 +23,32 @@ def copyToFinalPosition(String pathToIntermediate, String finalBaseFolder, Strin } // Given details about artifacts to import and details of installers to build, import artifacts that are required -def Map artifactsImporter(meta, importer, artifactDetails, installerDetails) { +def Map artifactsImporter(meta, importer, toBuild, artifactDetails, installerDetails, boolean showdetails = false) { artifactFetched = [:] + if (showdetails) { + echo ("toBuild:\n${toBuild}\nartifactDetails:\n${artifactDetails}\ninstallerDetails:\n${installerDetails}") + } def importoptions = importer.getNewImportOptions() + importoptions.showdetails(showdetails) for (installer in toBuild) { - def artifactKeys = installerDetails.get(installer)[1] + def installerinfo = installerDetails.get(installer) + if (showdetails) { + echo ("installer:\n${installer}\ninstallerinfo:\n${installerinfo}") + } + def artifactKeys = installerinfo[1] if (artifactKeys instanceof java.lang.String) { artifactKeys = [ artifactKeys ] } + if (showdetails) { + echo ("artifactKeys:\n${artifactKeys}") + } for (artifactKey in artifactKeys) { - (sourceProject, sourceselector, destFolder, incrementversionnumber, toCopy, notToCopy, binariesFolders) = artifactDetails.get(artifactKey) + artifactDetail = artifactDetails.get(artifactKey) + if (showdetails) { + echo ("artifactKey: ${artifactKey}\nartifactDetail:\n${artifactDetail}") + } + (sourceProject, sourceselector, destFolder, incrementversionnumber, toCopy, notToCopy, binariesFolders) = artifactDetail if (artifactFetched.get(artifactKey) == null) { importoptions.jenkinsjob(sourceProject, sourceselector) importoptions.setincrementversionnumber(incrementversionnumber) @@ -45,6 +60,9 @@ def Map artifactsImporter(meta, importer, artifactDetails, installerDetails) { } } } + if (showdetails) { + echo ("artifactFetched:\n${artifactFetched}") + } return artifactFetched } @@ -93,6 +111,7 @@ def checkISMfilebackend(String xml) { def checkISMfile(String ISMfile) { echo "Checking ISM file: ${ISMfile}" def xml = readFile(ISMfile) + //echo "ISM file xml: ${xml}" (exitcode, message) = checkISMfilebackend(xml) echo message if (exitcode > 0) { diff --git a/meta/folder.groovy b/meta/folder.groovy index b9e898c..6715145 100644 --- a/meta/folder.groovy +++ b/meta/folder.groovy @@ -608,6 +608,7 @@ class MetaInfo extends GISJsonSerialised { abstract void deserialiseJson(rawmeta) abstract LinkedHashMap serialisationdata() abstract String getrelatedid() + abstract void markreleased() } class RelatedMetaInfo_v0_1 extends RelatedMetaInfo { @@ -642,6 +643,10 @@ class MetaInfo extends GISJsonSerialised { String getrelatedid() { return uniqueid } + + void markreleased() { + meta.releaseinfo.markreleased() + } } class RelatedMetaInfo_v0_2 extends RelatedMetaInfo { @@ -674,6 +679,10 @@ class MetaInfo extends GISJsonSerialised { String getrelatedid() { return uniqueid } + + void markreleased() { + // Do nothing + } } private ProductInfo productinfo @@ -701,15 +710,11 @@ class MetaInfo extends GISJsonSerialised { associatedmeta = new ArrayList() } - List getassociated() { - return associatedmeta - } - void markreleased() { script.echo("Marking product: ${productinfo.productname} component: ${productinfo.subcomponentname} as released") releaseinfo.markreleased() for (associated in associatedmeta) { - associated.meta.releaseinfo.markreleased() + associated.markreleased() } } @@ -1079,6 +1084,7 @@ class MetaInfo extends GISJsonSerialised { return [ 'metacollection' : ii.metacollection, 'metamap' : ii.metamap, 'comment': ii.comment ] } + // Walks all layers of associated data only def allrelatedmeta(String metapath = '') { def ArrayList metacollection = new ArrayList() def Map metamap = new LinkedHashMap() @@ -1088,10 +1094,17 @@ class MetaInfo extends GISJsonSerialised { ArrayList releasewalker(int maxdepth, String startpath = '', String startmetapath = '') { def ArrayList metacollection = new ArrayList() def Map metamap = new LinkedHashMap() - def results = walkrelated(new IterationInfo(metacollection, metamap, 'meta', 0, startpath, startmetapath, true, maxdepth)) + def IterationInfo ii = new IterationInfo(metacollection, metamap, 'meta', 0, startpath, startmetapath, true, maxdepth) + script.echo("Release walker iteration info at start:\n${ii.show()}") + def results = walkrelated(ii) return results.metacollection } + // Walks 1 layer of associated data only + def getassociated(String rootpath) { + return releasewalker(2, '', "${rootpath}/${METAFOLDERNAME}") // Max depth 2 (including itself) + } + Map putwithshortestoffsetpath(Map releasemetacollection, String uniquestring, CollectedMeta metaitem) { if (releasemetacollection.containsKey(uniquestring)) { def existingentry = releasemetacollection[uniquestring]