Better regexp, remove workspace cleanup
This commit is contained in:
parent
1d416ce821
commit
188e6f1ab3
@ -15,6 +15,9 @@
|
||||
},
|
||||
"Indentation": {
|
||||
"enabled": false
|
||||
},
|
||||
"NoDef": {
|
||||
"enabled": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,14 +3,10 @@
|
||||
void call(Map config = [:], Closure body = { }) {
|
||||
Map defaults = [
|
||||
stepName: 'Checkout',
|
||||
useJobSCM: true,
|
||||
cleanWorkspace: true
|
||||
useJobSCM: true
|
||||
]
|
||||
runConfig = defaults + config
|
||||
stage(runConfig.stepName) {
|
||||
if (runConfig.cleanWorkspace) {
|
||||
cleanWs disableDeferredWipeout: true
|
||||
}
|
||||
printBanner(runConfig.stepName)
|
||||
if (runConfig.useJobSCM) {
|
||||
checkout scm
|
||||
|
||||
@ -26,8 +26,7 @@ Map call(Map config = [:], Map queryParams = [:]) {
|
||||
Map runConfig = defaults + config
|
||||
Map query = queryParamsDefaults + queryParams
|
||||
|
||||
def version
|
||||
def response
|
||||
String version
|
||||
|
||||
nexusURL = runConfig.nexusBase + '/' + runConfig.searchAPI
|
||||
nexusSearch = buildUrlWithQueryParams(nexusURL, query)
|
||||
@ -37,18 +36,17 @@ Map call(Map config = [:], Map queryParams = [:]) {
|
||||
url: nexusSearch,
|
||||
wrapAsMultipart: false
|
||||
|
||||
|
||||
body = response.content
|
||||
assets = readJSON text: body
|
||||
if (assets.items && !assets.items.isEmpty()) {
|
||||
if (assets.items && !assets.items.empty) {
|
||||
latest = assets.items.last()
|
||||
/* 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
|
||||
plugin. */
|
||||
/* groovylint-disable-next-line Instanceof */
|
||||
if (latest.version instanceof net.sf.json.JSONNull && latest.name) {
|
||||
echo "Search result version field was null, looking in name field for a version"
|
||||
def match = (latest.name =~ /(?<=-)([0-9\.]{1,3})(?:-|\.)[^-\.]+/)
|
||||
echo 'Search result version field was null, looking in name field for a version'
|
||||
match = (latest.name =~ /(?<=-)(\d+\.\d+\.\d+)(?=[\.-].*)/)
|
||||
if (!match) {
|
||||
echo "Match: ${match}"
|
||||
error("Regular expression match failed for latest.name: ${latest.name}")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user