Add publish item selector script
This commit is contained in:
parent
6cc9f1928d
commit
39d54ecfa0
2 changed files with 49 additions and 14 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import java.nio.file.Paths
|
||||
import java.nio.file.Path
|
||||
import groovy.json.JsonSlurperClassic
|
||||
|
||||
abstract class GISJsonSerialised implements Serializable {
|
||||
def script
|
||||
|
|
@ -552,7 +553,13 @@ class MetaInfo extends GISJsonSerialised {
|
|||
def rawmeta = script.readJSON(file: filepath)
|
||||
deserialiseJson(rawmeta)
|
||||
}
|
||||
|
||||
|
||||
def deserialiseJsonSlurper(String filepath) {
|
||||
def jsonfile = readFile(file: filepath)
|
||||
def rawmeta = new JsonSlurperClassic().parseText(jsonfile)
|
||||
deserialiseJson(rawmeta)
|
||||
}
|
||||
|
||||
String relativize(String mypath) {
|
||||
String pathRelative
|
||||
script.echo("Seeing if ${mypath} begins with ${script.WORKSPACE}")
|
||||
|
|
@ -726,4 +733,10 @@ MetaInfo metafromfolder(String folder = "") {
|
|||
return buildmeta
|
||||
}
|
||||
|
||||
MetaInfo metafromfolderSlurper(String folder = "") {
|
||||
MetaInfo buildmeta = new MetaInfo(this)
|
||||
buildmeta.deserialiseJsonSlurper("${folder}/${MetaInfo.metafilepath()}")
|
||||
return buildmeta
|
||||
}
|
||||
|
||||
return this;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#!/usr/local/bin/groovy
|
||||
jobname="anything"
|
||||
metarepoext = "git@hydra:HMB_XR_5601_Releases/hmb_xr_5601_whole.git"
|
||||
metalevels = 2
|
||||
|
||||
commonscriptsrepo="git@hydra:jenkinsautobuild/Common_scripts.git"
|
||||
|
||||
|
|
@ -48,13 +50,25 @@ def gitCloneOrPull(String repo, String folder) {
|
|||
return [sout, serr]
|
||||
}
|
||||
|
||||
def loadmetaclass(String commonscripts) {
|
||||
def loadmetaclass(String commonscripts, String metafolder) {
|
||||
def metafolderscriptfile = "${commonscripts}/meta/folder.groovy"
|
||||
log("Loading script: ${metafolderscriptfile}")
|
||||
def script = new GroovyScriptEngine('.').with {
|
||||
loadScriptByName(metafolderscriptfile)
|
||||
}
|
||||
return script
|
||||
|
||||
GroovyShell shell = new GroovyShell()
|
||||
def metafolderscript = shell.parse(new File(metafolderscriptfile))
|
||||
log("metafolderscript is ${metafolderscript.getClass()}")
|
||||
def meta = metafolderscript.metafromfolder(metafolder)
|
||||
log("meta is ${meta.getClass()}")
|
||||
|
||||
|
||||
|
||||
//Class<MetaInfo> groovyClass = new GroovyClassLoader(getClass().getClassLoader()).parseClass(metafolderscriptfile)
|
||||
//log("groovyClass is ${groovyClass.getClass()}")
|
||||
//GroovyObject metafolderobject = (GroovyObject) groovyClass.newInstance()
|
||||
//log("metafolderobject is ${metafolderobject.getClass()}")
|
||||
//metaObject = new metafolderobject.MetaInfo(this)
|
||||
//log("metaobject is ${metaObject.getClass()}")
|
||||
return meta
|
||||
}
|
||||
|
||||
def String makeworking() {
|
||||
|
|
@ -67,10 +81,19 @@ def String makeworking() {
|
|||
createfolder(rootfolder)
|
||||
|
||||
def commonscripts = "${rootfolder}/commonscripts"
|
||||
gitCloneOrPull(commonscriptsrepo, commonscripts);
|
||||
gitCloneOrPull(commonscriptsrepo, commonscripts)
|
||||
|
||||
def metascript = loadmetaclass(commonscripts)
|
||||
return metascript
|
||||
// Clone or pull the relevant meta repo
|
||||
def metareporoot = "${rootfolder}/${jobname}"
|
||||
gitCloneOrPull(metarepoext, metareporoot)
|
||||
def metafolder = "${metareporoot}/meta"
|
||||
|
||||
// Load the meta folder class that interprets the meta repo
|
||||
def metascript = loadmetaclass(commonscripts, metafolder)
|
||||
|
||||
// Read in the meta
|
||||
meta = metascript.metafromfolder(metafolder)
|
||||
return meta
|
||||
}
|
||||
|
||||
def List<String> getItems() {
|
||||
|
|
@ -79,7 +102,7 @@ def List<String> getItems() {
|
|||
log("Getting items")
|
||||
def p = ['pwd'].execute()
|
||||
p.waitFor()
|
||||
items.add(p.text)
|
||||
items.add(p.text.trim())
|
||||
items.add(metarepoext)
|
||||
items.add(metalevels)
|
||||
|
||||
|
|
@ -95,10 +118,9 @@ def List<String> getItems() {
|
|||
}
|
||||
|
||||
makeworking()
|
||||
loadmetaclass()
|
||||
count = 0
|
||||
for (item in getItems()) {
|
||||
log (count)
|
||||
def items = getItems()
|
||||
for (item in items) {
|
||||
count += 1
|
||||
log (item)
|
||||
log ("${count}: ${item}")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue