Add Versioning without grab
This commit is contained in:
parent
d2d4e5b6f9
commit
c0f2e31b97
@ -1,19 +1,32 @@
|
|||||||
#!/usr/bin/env groovy
|
#!/usr/bin/env groovy
|
||||||
|
|
||||||
import groovyx.net.http.URIBuilder
|
import java.net.URLEncoder
|
||||||
|
|
||||||
Map call(Map config = [:]) {
|
Map call(Map config = [:]) {
|
||||||
Map defaults = [
|
Map defaults = [
|
||||||
nexusBase: 'https://repo.thejimnicholson.com',
|
nexusBase: 'https://repo.thejimnicholson.com',
|
||||||
searchAPI: 'service/rest/v1/search',
|
searchAPI: 'service/rest/v1/search',
|
||||||
repositoryName: 'tools'
|
queryParams: [
|
||||||
|
'repository': 'tools',
|
||||||
|
'sort': 'name',
|
||||||
|
'name': 'test.something'
|
||||||
|
]
|
||||||
]
|
]
|
||||||
Map runConfig = defaults + config
|
Map runConfig = defaults + config
|
||||||
|
|
||||||
nexusSearch = new URIBuilder(runConfig.nexusBase)
|
nexusSearch = buildUrlWithQueryParams(runConfig.nexusBase, runConfig.queryParams)
|
||||||
/* groovylint-disable-next-line UnnecessarySetter */
|
|
||||||
nexusSearch.setPath(runConfig.searchAPI)
|
|
||||||
nexusSearch.addQueryParam('repository', runConfig.repositoryName)
|
|
||||||
runConfig.nexusQuery = nexusSearch
|
runConfig.nexusQuery = nexusSearch
|
||||||
return runConfig
|
return runConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def buildUrlWithQueryParams(baseUrl, queryParams) {
|
||||||
|
def url = baseUrl
|
||||||
|
if (!queryParams.empty) {
|
||||||
|
def queryParamsString = queryParams.collect { key, value ->
|
||||||
|
"${URLEncoder.encode(key, 'UTF-8')}=${URLEncoder.encode(value, 'UTF-8')}"
|
||||||
|
}.join('&')
|
||||||
|
url += '?' + queryParamsString
|
||||||
|
}
|
||||||
|
return url
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user