Refine the parsing to work with various situations
This commit is contained in:
parent
d0073f3c4e
commit
96ee3f0051
@ -36,17 +36,20 @@ Map call(Map config = [:], Map queryParams = [:]) {
|
|||||||
body = response.content
|
body = response.content
|
||||||
assets = readJSON text: body
|
assets = readJSON text: body
|
||||||
latest = assets.items.last()
|
latest = assets.items.last()
|
||||||
version = latest.version
|
version = latest.version ?: (latest.name =~ /.*-([0-9\.]+)-([0-9]+)\..*/)[0][1]
|
||||||
build = 0
|
build = latest.version ?: (latest.name =~ /.*-([0-9\.]+)-([0-9]+)\..*/)[0][2]
|
||||||
buildNumFromQuery = '1'
|
|
||||||
if ((latest.version ?: null) == null) {
|
if (version == null) {
|
||||||
matches = (latest.name =~ /.*-([0-9\.]+)-([0-9]+)\.)[0]/)[0]
|
// Call the error method and pass a string indicating version was null and name is not parseable
|
||||||
version = matches[1]
|
error('Version was null and name is not parseable')
|
||||||
build = matches[2]
|
|
||||||
}
|
}
|
||||||
runConfig.nexusQuery = nexusSearch
|
|
||||||
runConfig.latestVersion = version
|
if (build == null) {
|
||||||
runConfig.latestBuild = build
|
unstable("Build number could not be found in latest asset match (${latest.name})")
|
||||||
|
}
|
||||||
|
build = build ?: env.BUILD_NUMBER
|
||||||
|
runConfig.version = version
|
||||||
|
runConfig.build = build
|
||||||
return runConfig
|
return runConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user