Better regexp, remove workspace cleanup
This commit is contained in:
parent
1d416ce821
commit
188e6f1ab3
@ -15,6 +15,9 @@
|
|||||||
},
|
},
|
||||||
"Indentation": {
|
"Indentation": {
|
||||||
"enabled": false
|
"enabled": false
|
||||||
|
},
|
||||||
|
"NoDef": {
|
||||||
|
"enabled": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3,14 +3,10 @@
|
|||||||
void call(Map config = [:], Closure body = { }) {
|
void call(Map config = [:], Closure body = { }) {
|
||||||
Map defaults = [
|
Map defaults = [
|
||||||
stepName: 'Checkout',
|
stepName: 'Checkout',
|
||||||
useJobSCM: true,
|
useJobSCM: true
|
||||||
cleanWorkspace: true
|
|
||||||
]
|
]
|
||||||
runConfig = defaults + config
|
runConfig = defaults + config
|
||||||
stage(runConfig.stepName) {
|
stage(runConfig.stepName) {
|
||||||
if (runConfig.cleanWorkspace) {
|
|
||||||
cleanWs disableDeferredWipeout: true
|
|
||||||
}
|
|
||||||
printBanner(runConfig.stepName)
|
printBanner(runConfig.stepName)
|
||||||
if (runConfig.useJobSCM) {
|
if (runConfig.useJobSCM) {
|
||||||
checkout scm
|
checkout scm
|
||||||
|
|||||||
@ -26,29 +26,27 @@ Map call(Map config = [:], Map queryParams = [:]) {
|
|||||||
Map runConfig = defaults + config
|
Map runConfig = defaults + config
|
||||||
Map query = queryParamsDefaults + queryParams
|
Map query = queryParamsDefaults + queryParams
|
||||||
|
|
||||||
def version
|
String version
|
||||||
def response
|
|
||||||
|
|
||||||
nexusURL = runConfig.nexusBase + '/' + runConfig.searchAPI
|
nexusURL = runConfig.nexusBase + '/' + runConfig.searchAPI
|
||||||
nexusSearch = buildUrlWithQueryParams(nexusURL, query)
|
nexusSearch = buildUrlWithQueryParams(nexusURL, query)
|
||||||
|
|
||||||
response = httpRequest acceptType: 'APPLICATION_JSON',
|
response = httpRequest acceptType: 'APPLICATION_JSON',
|
||||||
contentType: 'APPLICATION_JSON',
|
contentType: 'APPLICATION_JSON',
|
||||||
url: nexusSearch,
|
url: nexusSearch,
|
||||||
wrapAsMultipart: false
|
wrapAsMultipart: false
|
||||||
|
|
||||||
|
|
||||||
body = response.content
|
body = response.content
|
||||||
assets = readJSON text: body
|
assets = readJSON text: body
|
||||||
if (assets.items && !assets.items.isEmpty()) {
|
if (assets.items && !assets.items.empty) {
|
||||||
latest = assets.items.last()
|
latest = assets.items.last()
|
||||||
/* We have to use instanceof here. The value SHOULD be null, but it comes back
|
/* We have to use instanceof here. The value SHOULD be null, but it comes back
|
||||||
as class rather than null. This is probably a bug in the Pipeline Utilities
|
as class rather than null. This is probably a bug in the Pipeline Utilities
|
||||||
plugin. */
|
plugin. */
|
||||||
/* groovylint-disable-next-line Instanceof */
|
/* groovylint-disable-next-line Instanceof */
|
||||||
if (latest.version instanceof net.sf.json.JSONNull && latest.name) {
|
if (latest.version instanceof net.sf.json.JSONNull && latest.name) {
|
||||||
echo "Search result version field was null, looking in name field for a version"
|
echo 'Search result version field was null, looking in name field for a version'
|
||||||
def match = (latest.name =~ /(?<=-)([0-9\.]{1,3})(?:-|\.)[^-\.]+/)
|
match = (latest.name =~ /(?<=-)(\d+\.\d+\.\d+)(?=[\.-].*)/)
|
||||||
if (!match) {
|
if (!match) {
|
||||||
echo "Match: ${match}"
|
echo "Match: ${match}"
|
||||||
error("Regular expression match failed for latest.name: ${latest.name}")
|
error("Regular expression match failed for latest.name: ${latest.name}")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user