forked from jenkins-infra/crawler
-
Notifications
You must be signed in to change notification settings - Fork 1
/
chromedriver.groovy
executable file
·33 lines (29 loc) · 1.03 KB
/
chromedriver.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
#!./lib/runner.groovy
// Generates server-side metadata for chromedriver auto-installation
import net.sf.json.*
import groovy.util.XmlSlurper
def baseUrl = 'http://chromedriver.storage.googleapis.com/'
def json = []
def map = [:].withDefault {[:].withDefault {[:]}}
def xml = new XmlSlurper().parseText(new URL(baseUrl).text)
xml.Contents.each {
def key = it.Key.text()
def m = key =~ /(.*)\/chromedriver_(.*?)(\d+)\.zip/
if (m) {
def (_, version, os, arch) = m[0]
map[os][arch][version] = key
json << ["id":"${os}${arch}_${version}".toString(), "url":baseUrl + key];
}
}
map.each { os, arch ->
if (arch.size() == 1) {
def latest = arch.find().value.max { it.key }
json << ["id":os, "url":baseUrl + latest.value];
} else {
arch.each { k, v ->
def latest = v.max { it.key }
json << ["id":os + k, "url":baseUrl + latest.value];
}
}
}
lib.DataWriter.write("org.jenkins-ci.plugins.chromedriver.ChromeDriver",JSONObject.fromObject([list:json]));