diff --git a/.groovylintrc.json b/.groovylintrc.json index 9d29fff..afd953e 100644 --- a/.groovylintrc.json +++ b/.groovylintrc.json @@ -15,6 +15,9 @@ }, "Indentation": { "enabled": false + }, + "NoDef": { + "enabled": false } } } \ No newline at end of file diff --git a/vars/checkoutStep.groovy b/vars/checkoutStep.groovy index 4c68a52..569c87d 100644 --- a/vars/checkoutStep.groovy +++ b/vars/checkoutStep.groovy @@ -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 diff --git a/vars/findVersionFromNexusRepo.groovy b/vars/findVersionFromNexusRepo.groovy index 93422b0..aeb4d39 100644 --- a/vars/findVersionFromNexusRepo.groovy +++ b/vars/findVersionFromNexusRepo.groovy @@ -26,29 +26,27 @@ 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) - + response = httpRequest acceptType: 'APPLICATION_JSON', contentType: 'APPLICATION_JSON', 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}")