-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathleiningen.groovy
executable file
·29 lines (22 loc) · 1.03 KB
/
leiningen.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 Leiningen 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 baseUrl = 'https://github.com'
HtmlPage p = wc.getPage(baseUrl + '/technomancy/leiningen/releases');
// curl 'https://api.github.com/repos/technomancy/leiningen/releases' | jq '.[].assets[].name,.[].assets[].browser_download_url'
def json = [];
p.getByXPath("//a[@href]").reverse().collect { HtmlAnchor e ->
def url = baseUrl + e.getHrefAttribute()
def m = (url =~ /leiningen-(.*)-standalone.jar$/)
if (m) {
json << ["id":m[0][1], "name": "Leiningen ${m[0][1]}".toString(), "url":url];
}
}
lib.DataWriter.write("org.jenkins-ci.plugins.leiningen.LeinInstaller",JSONObject.fromObject([list:json]));