-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathcodeql.groovy
executable file
·46 lines (34 loc) · 1.36 KB
/
codeql.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
35
36
37
38
39
40
41
42
43
44
45
46
#!./lib/runner.groovy
// Generates server-side metadata for Gradle auto-installation
import org.htmlunit.Page
import org.htmlunit.WebClient
import org.htmlunit.WebResponse
import net.sf.json.*
def wc = new WebClient();
wc.addRequestHeader("accept", "application/json")
wc.getOptions().setThrowExceptionOnFailingStatusCode(false);
wc.getOptions().setPrintContentOnFailingStatusCode(false);
def API_URL = "https://api.github.com";
Page p = wc.getPage(API_URL + "/repos/github/codeql-action/releases")
WebResponse response = p.getWebResponse();
if (response.statusCode != 200) {
throw new Exception("Could not load available_releases")
}
JSONArray result = new JSONArray()
JSONArray data = JSONArray.fromObject(response.getContentAsString())
data.each { release ->
JSONObject r = new JSONObject()
def tagname = release.tag_name
if(!(tagname =~ /codeql-bundle-(.*)/)) {
return
}
def bundleDate = (tagname =~ /codeql-bundle-(.*)/)[0][1]
def bundleversion = ( release.body =~ /.*v([0-9]+\.[0-9]+\..*)/)[0][1]
r.put("id", bundleversion )
r.put("name", bundleversion)
r.put("url", "https://github.com/github/codeql-action/releases/download/" + tagname + '/')
result.add(r)
}
JSONObject resultObj = new JSONObject()
.element("list", result);
lib.DataWriter.write("io.jenkins.plugins.codeql.CodeQLInstaller", resultObj);