-
Notifications
You must be signed in to change notification settings - Fork 67
/
mongodb.groovy
executable file
·29 lines (26 loc) · 1.09 KB
/
mongodb.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
#!./lib/runner.groovy
// Generates server-side metadata for MongoDB auto-installation
import org.htmlunit.html.*;
import net.sf.json.*
import org.htmlunit.WebClient
def wc = new WebClient()
wc.setCssErrorHandler(new org.htmlunit.SilentCssErrorHandler());
wc.getOptions().setJavaScriptEnabled(false);
wc.getOptions().setThrowExceptionOnScriptError(false);
wc.getOptions().setThrowExceptionOnFailingStatusCode(false);
def json = [];
[osx: ['i386', 'x86_64'],
linux: ['i686', 'x86_64'],
win32: ['i386', 'x86_64'],
sunos5: ['i86pc', 'x86_64']
].each { osname, archs -> archs.each { arch ->
HtmlPage p = wc.getPage("http://dl.mongodb.org/dl/$osname/$arch")
p.getByXPath("//a[@href]").reverse().collect { HtmlAnchor e ->
def m = e.getHrefAttribute() =~ /^.*mongodb-$osname-$arch-(.*?)\.(tgz|zip)$/
if (m) {
String version = "${osname}-${arch}-${m[0][1]}"
json << [id:version, name:version, url:m[0][0].replace('http://', 'https://')]
}
}
}}
lib.DataWriter.write("org.jenkinsci.plugins.mongodb.MongoDBInstaller",JSONObject.fromObject([list:json]));