Improve uriByProperties Artifactory method
Make it possible to pass a list of repositories to search in
Related story: PROD-30459
Change-Id: Id04b00392ad6f77291173a153a5417acf327c4c5
diff --git a/src/com/mirantis/mcp/MCPArtifactory.groovy b/src/com/mirantis/mcp/MCPArtifactory.groovy
index b10c1be..0a98ea3 100644
--- a/src/com/mirantis/mcp/MCPArtifactory.groovy
+++ b/src/com/mirantis/mcp/MCPArtifactory.groovy
@@ -40,9 +40,10 @@
* which should determine artifact in Artifactory
* @param onlyLastItem Boolean, return only last URL if true(by default),
* else return list of all found artifact URLS
+ * @param repos ArrayList, a list of repositories to search in
*
*/
-def uriByProperties(String artifactoryURL, LinkedHashMap properties, Boolean onlyLastItem=true) {
+def uriByProperties(String artifactoryURL, LinkedHashMap properties, Boolean onlyLastItem=true, ArrayList repos=[]) {
def key, value
def properties_str = ''
for (int i = 0; i < properties.size(); i++) {
@@ -51,7 +52,13 @@
value = properties.entrySet().toArray()[i].value.trim()
properties_str += /${key}=${value}&/
}
- def search_url = "${artifactoryURL}/api/search/prop?${properties_str}"
+ def repos_str = (repos) ? repos.join(',') : ''
+ def search_url
+ if (repos_str) {
+ search_url = "${artifactoryURL}/api/search/prop?${properties_str}&repos=${repos_str}"
+ } else {
+ search_url = "${artifactoryURL}/api/search/prop?${properties_str}"
+ }
def result = sh(script: /curl -X GET '${search_url}'/,
returnStdout: true).trim()