forked from jenkins-infra/crawler
-
Notifications
You must be signed in to change notification settings - Fork 1
/
scriptler.groovy
executable file
·34 lines (28 loc) · 983 Bytes
/
scriptler.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
// Generates index for scriptler scripts
import net.sf.json.*
def json = [];
def dir = new File("./jenkins-scripts");
if (dir.isDirectory() && new File(dir, ".git").isDirectory()) {
"git pull --rebase origin master".execute([], dir).waitFor()
} else {
dir.mkdirs()
"git clone git://github.com/jenkinsci/jenkins-scripts -b master".execute().waitFor()
}
def scriptlerDir = new File(dir, "scriptler")
scriptlerDir.eachFileMatch(~/.+\.groovy/) { File f ->
if(f.name.equals('testMetaFormat.groovy')) {
return
}
def m = (f.text =~ /(?ms)BEGIN META(.+?)END META/)
if (m) {
try {
def metadata = JSONObject.fromObject(m[0][1]);
metadata['script'] = f.name
json << metadata
} catch (Exception e) {
e.printStackTrace(System.err);
}
}
}
lib.DataWriter.write("org.jenkinsci.plugins.scriptler.CentralScriptJsonCatalog",JSONObject.fromObject([list:json]));