Merge commit '2426465d7d'
This commit is contained in:
commit
d83ce0174e
6 changed files with 187 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
|
import groovy.json.JsonSlurperClassic
|
||||||
|
|
||||||
abstract class GISJsonSerialised implements Serializable {
|
abstract class GISJsonSerialised implements Serializable {
|
||||||
def script
|
def script
|
||||||
|
|
@ -552,7 +553,14 @@ class MetaInfo extends GISJsonSerialised {
|
||||||
def rawmeta = script.readJSON(file: filepath)
|
def rawmeta = script.readJSON(file: filepath)
|
||||||
deserialiseJson(rawmeta)
|
deserialiseJson(rawmeta)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def deserialiseJsonSlurper(String filepath) {
|
||||||
|
File jsonfile = new File(filepath)
|
||||||
|
def jsonfiletext = jsonfile.getText()
|
||||||
|
def rawmeta = new JsonSlurperClassic().parseText(jsonfiletext)
|
||||||
|
deserialiseJson(rawmeta)
|
||||||
|
}
|
||||||
|
|
||||||
String relativize(String mypath) {
|
String relativize(String mypath) {
|
||||||
String pathRelative
|
String pathRelative
|
||||||
script.echo("Seeing if ${mypath} begins with ${script.WORKSPACE}")
|
script.echo("Seeing if ${mypath} begins with ${script.WORKSPACE}")
|
||||||
|
|
@ -726,4 +734,10 @@ MetaInfo metafromfolder(String folder = "") {
|
||||||
return buildmeta
|
return buildmeta
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MetaInfo metafromfolderSlurper(String folder = "") {
|
||||||
|
MetaInfo buildmeta = new MetaInfo(this)
|
||||||
|
buildmeta.deserialiseJsonSlurper("${folder}/${MetaInfo.metafilepath()}")
|
||||||
|
return buildmeta
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|
|
||||||
9
publish/.classpath
Normal file
9
publish/.classpath
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
|
<classpathentry excluding="publish.groovy" kind="src" path=""/>
|
||||||
|
<classpathentry exported="true" kind="con" path="GROOVY_SUPPORT"/>
|
||||||
|
<classpathentry exported="true" kind="con" path="GROOVY_DSL_SUPPORT"/>
|
||||||
|
<classpathentry kind="lib" path="/home/dan/.sdkman/candidates/groovy/2.5.6/lib/groovy-json-2.5.6.jar"/>
|
||||||
|
<classpathentry kind="output" path=""/>
|
||||||
|
</classpath>
|
||||||
7
publish/.gitignore
vendored
Normal file
7
publish/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
/do$_publish_closure4.class
|
||||||
|
/do$_resetfolders_closure1.class
|
||||||
|
/do$_resetfolders_closure2.class
|
||||||
|
/do$_resetfolders_closure3.class
|
||||||
|
/do$_stripgithistory_closure5.class
|
||||||
|
/do.class
|
||||||
|
/publish_item_select.class
|
||||||
18
publish/.project
Normal file
18
publish/.project
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>publish_item_select</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.groovy.core.groovyNature</nature>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
3
publish/.settings/org.eclipse.jdt.groovy.core.prefs
Normal file
3
publish/.settings/org.eclipse.jdt.groovy.core.prefs
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
groovy.compiler.level=25
|
||||||
|
groovy.script.filters=**/*.dsld,y,**/*.gradle,n
|
||||||
135
publish/publish_item_select.groovy
Executable file
135
publish/publish_item_select.groovy
Executable file
|
|
@ -0,0 +1,135 @@
|
||||||
|
#!/usr/local/bin/groovy
|
||||||
|
|
||||||
|
jobnameext = jobname ?: "jobunique"
|
||||||
|
metarepoext = metarepo ?: "git@hydra:print-server-releases/print_server_whole.git"
|
||||||
|
outputselectext = outputselect ?: "description"
|
||||||
|
metalevelsstringext = metalevels ?: "2"
|
||||||
|
|
||||||
|
//jobnameext = "jobunique"
|
||||||
|
//metarepoext = "git@hydra:print-server-releases/print_server_whole.git"
|
||||||
|
//outputselectext = "description"
|
||||||
|
//metalevelsstringext = "2"
|
||||||
|
|
||||||
|
metalevelsext = metalevelsstringext.toInteger()
|
||||||
|
dolog = false
|
||||||
|
|
||||||
|
commonscriptsrepo="git@hydra:jenkinsautobuild/Common_scripts.git"
|
||||||
|
|
||||||
|
def log(message) {
|
||||||
|
if (dolog) {
|
||||||
|
println message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def createfolder(String folder) {
|
||||||
|
def sout = new StringBuilder()
|
||||||
|
def serr = new StringBuilder()
|
||||||
|
|
||||||
|
log("Creating directory: ${folder}")
|
||||||
|
def s = ['mkdir', '-p', folder].execute()
|
||||||
|
s.consumeProcessOutput(sout, serr)
|
||||||
|
s.waitFor()
|
||||||
|
|
||||||
|
log("Out: ${sout} Err: ${serr}")
|
||||||
|
return [sout, serr]
|
||||||
|
}
|
||||||
|
|
||||||
|
def gitCloneOrPull(String repo, String folder) {
|
||||||
|
def sout = new StringBuilder()
|
||||||
|
def serr = new StringBuilder()
|
||||||
|
|
||||||
|
if (!(new File(folder).exists())) {
|
||||||
|
log("Cloning: ${repo} to: ${folder}")
|
||||||
|
createfolder(folder)
|
||||||
|
def s = ['git', 'clone', repo, folder].execute()
|
||||||
|
s.consumeProcessOutput(sout, serr)
|
||||||
|
s.waitFor()
|
||||||
|
} else {
|
||||||
|
log("Pull in: ${folder}")
|
||||||
|
def s = ['git', 'pull'].execute(null, new File(folder))
|
||||||
|
s.consumeProcessOutput(sout, serr)
|
||||||
|
s.waitFor()
|
||||||
|
}
|
||||||
|
|
||||||
|
log("Out: ${sout} Err: ${serr}")
|
||||||
|
return [sout, serr]
|
||||||
|
}
|
||||||
|
|
||||||
|
def loadmetaclass(String commonscripts, String metafolder) {
|
||||||
|
def metafolderscriptfile = "${commonscripts}/meta/folder.groovy"
|
||||||
|
|
||||||
|
GroovyShell shell = new GroovyShell()
|
||||||
|
def metafolderscript = shell.parse(new File(metafolderscriptfile))
|
||||||
|
def meta = metafolderscript.metafromfolderSlurper(metafolder)
|
||||||
|
return meta
|
||||||
|
}
|
||||||
|
|
||||||
|
def makeworking() {
|
||||||
|
def r = ['whoami'].execute()
|
||||||
|
r.waitFor()
|
||||||
|
def user = r.text.trim()
|
||||||
|
|
||||||
|
def rootfolder = "/home/${user}/tmp"
|
||||||
|
createfolder(rootfolder)
|
||||||
|
|
||||||
|
def commonscripts = "${rootfolder}/commonscripts"
|
||||||
|
gitCloneOrPull(commonscriptsrepo, commonscripts)
|
||||||
|
|
||||||
|
// Clone or pull the relevant meta repo
|
||||||
|
def metareporoot = "${rootfolder}/${jobnameext}"
|
||||||
|
gitCloneOrPull(metarepoext, metareporoot)
|
||||||
|
def metafolder = "${metareporoot}/meta"
|
||||||
|
|
||||||
|
// Load the meta folder class that interprets the meta repo
|
||||||
|
def meta = loadmetaclass(commonscripts, metareporoot)
|
||||||
|
return meta
|
||||||
|
}
|
||||||
|
|
||||||
|
def String outputDescription(menuitems, releaseinfo) {
|
||||||
|
meta = releaseinfo.meta
|
||||||
|
|
||||||
|
for (publishableitem in meta.publishableinfo) {
|
||||||
|
menuitems.add("${meta.productinfo.productname} ${meta.productinfo.subcomponentname} ${publishableitem.filepath}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def String outputSelection(menuitems, releaseinfo) {
|
||||||
|
meta = releaseinfo.meta
|
||||||
|
|
||||||
|
for (publishableitem in meta.publishableinfo) {
|
||||||
|
menuitems.add("${meta.productinfo.productname}#${meta.productinfo.subcomponentname}#${publishableitem.filepath}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def List<String> getItems(meta) {
|
||||||
|
def List<String> menuitems = new ArrayList<String>()
|
||||||
|
def metaitems = meta.releasewalkerunique(metalevelsext)
|
||||||
|
log("metaitems is ${metaitems.getClass()}")
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (key in metaitems.keySet()) {
|
||||||
|
def releaseinfo = metaitems[key]
|
||||||
|
if (outputselectext == "description") {
|
||||||
|
outputDescription(menuitems, releaseinfo)
|
||||||
|
}
|
||||||
|
if (outputselectext == "selection") {
|
||||||
|
outputSelection(menuitems, releaseinfo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return menuitems
|
||||||
|
} catch (Exception e) {
|
||||||
|
menuitems.add("Error ${e}")
|
||||||
|
return menuitems
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def meta = makeworking()
|
||||||
|
def items = getItems(meta)
|
||||||
|
|
||||||
|
count = 0
|
||||||
|
for (item in items) {
|
||||||
|
count += 1
|
||||||
|
log ("${count}: ${item}")
|
||||||
|
}
|
||||||
|
|
||||||
|
return items
|
||||||
Loading…
Add table
Add a link
Reference in a new issue