-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathallure.groovy
executable file
·72 lines (60 loc) · 2.38 KB
/
allure.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!./lib/runner.groovy
// Generates server-side metadata for Allure
import org.htmlunit.WebClient
import org.htmlunit.html.DomElement
import org.htmlunit.html.HtmlPage
import org.htmlunit.xml.XmlPage
import net.sf.json.JSONObject
def getList() {
List versions = new ArrayList()
versions.addAll(getCentralVersions())
versions.addAll(getSonatypeVersions())
return versions
}
def getCentralVersions() {
String baseUrl = 'https://repo1.maven.org/maven2/io/qameta/allure/allure-commandline'
URL metaUrl = new URL("$baseUrl/maven-metadata.xml")
WebClient wc = new WebClient()
XmlPage meta = wc.getPage(metaUrl)
List<String> versions = meta.getByXPath("//metadata/versioning/versions/version")
.collect() { DomElement e -> e.getTextContent() }
.findAll() { e -> !e.contains('BETA') }
.reverse()
return versions.collect() { version ->
return ["id" : version,
"name": version,
"url" : String.format('%s/%s/allure-commandline-%s.zip', baseUrl, version, version)
]
}
}
def getSonatypeVersions() {
String baseUrl = 'https://oss.sonatype.org/content/repositories/releases/ru/yandex/qatools/allure/allure-commandline'
URL metaUrl = new URL("$baseUrl/maven-metadata.xml")
WebClient wc = new WebClient()
XmlPage meta = wc.getPage(metaUrl)
List<String> versions = meta.getByXPath("//metadata/versioning/versions/version")
.collect() { DomElement e -> e.getTextContent() }
.findAll() { e -> !e.contains('RC') }
.reverse()
return versions.collect() { version ->
return ["id" : version,
"name": version,
"url" : getSonatypeArtifactUrl(baseUrl, version)
]
}
}
def getSonatypeArtifactUrl(String baseUrl, String version) {
def artifactName = getSonatypeArtifactName(version);
return String.format('%s/%s/%s', baseUrl, version, artifactName);
}
def getSonatypeArtifactName(String version) {
switch (version) {
case '1.4.17': return String.format('allure-commandline-%s.zip', version)
default: return String.format('allure-commandline-%s-standalone.zip', version)
}
}
def store(key, o) {
JSONObject envelope = JSONObject.fromObject(["list": o])
lib.DataWriter.write(key, envelope)
}
store("ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstaller", getList())