forked from jenkins-infra/crawler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgradle.groovy
More file actions
executable file
·27 lines (21 loc) · 899 Bytes
/
Copy pathgradle.groovy
File metadata and controls
executable file
·27 lines (21 loc) · 899 Bytes
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
#!./lib/runner.groovy
// Generates server-side metadata for Gradle auto-installation
import com.gargoylesoftware.htmlunit.html.*;
import com.gargoylesoftware.htmlunit.WebClient
import net.sf.json.*
def wc = new WebClient()
wc.setCssErrorHandler(new com.gargoylesoftware.htmlunit.SilentCssErrorHandler());
wc.getOptions().setThrowExceptionOnScriptError(false);
wc.getOptions().setThrowExceptionOnFailingStatusCode(false);
def baseUrl = 'https://services.gradle.org'
HtmlPage p = wc.getPage(baseUrl + '/distributions');
def json = [];
p.getByXPath("//a[@href]").collect { HtmlAnchor e ->
def url = baseUrl + e.getHrefAttribute()
println url
def m = (url =~ /gradle-(.*)-bin.zip$/)
if (m) {
json << ["id":m[0][1], "name": "Gradle ${m[0][1]}".toString(), "url":url];
}
}
lib.DataWriter.write("hudson.plugins.gradle.GradleInstaller",JSONObject.fromObject([list:json]));