-
Notifications
You must be signed in to change notification settings - Fork 67
/
recipe.groovy
executable file
·34 lines (29 loc) · 999 Bytes
/
recipe.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!./lib/runner.groovy
// generate metadata for recipes
import net.sf.json.*
import java.util.zip.*
def branch = "inbound";
// def zip = new File("recipes.zip");
def zip = File.createTempFile("recipes","zip");
zip.deleteOnExit()
zip.withOutputStream { o ->
new URL("https://github.com/jenkinsci/submitted-recipes/archive/${branch}.zip").withInputStream { i ->
o << i;
}
}
def json = [];
def z = new ZipFile(zip)
z.entries().each { e ->
if (e.name.endsWith(".jrcp")) {
def xml = new XmlSlurper().parse(z.getInputStream(e));
def o = [:];
["id","version","displayName","description","author"].each { p ->
o[p] = xml[p].toString();
}
o.timestamp = e.time
// TODO: copy it to our server
o.url = "https://raw.github.com/jenkinsci/submitted-recipes/${branch}/${o.id}.jrcp".toString()
json << o;
}
}
lib.DataWriter.write("org.jenkinsci.plugins.recipe.RecipeCatalog",JSONObject.fromObject([list:json]));