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
|
||||
assets = readJSON text: body
|
||||
latest = assets.items.last()
|
||||
version = latest.version
|
||||
build = 0
|
||||
buildNumFromQuery = '1'
|
||||
if ((latest.version ?: null) == null) {
|
||||
matches = (latest.name =~ /.*-([0-9\.]+)-([0-9]+)\.)[0]/)[0]
|
||||
version = matches[1]
|
||||
build = matches[2]
|
||||
version = latest.version ?: (latest.name =~ /.*-([0-9\.]+)-([0-9]+)\..*/)[0][1]
|
||||
build = latest.version ?: (latest.name =~ /.*-([0-9\.]+)-([0-9]+)\..*/)[0][2]
|
||||
|
||||
if (version == null) {
|
||||
// Call the error method and pass a string indicating version was null and name is not parseable
|
||||
error('Version was null and name is not parseable')
|
||||
}
|
||||
runConfig.nexusQuery = nexusSearch
|
||||
runConfig.latestVersion = version
|
||||
runConfig.latestBuild = build
|
||||
|
||||
if (build == null) {
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user