[artifactory.upload] Add additional methods
- getArtifactoryUrlByID
- getUploadSpec
Related-Prod: PRODX-54118
Change-Id: I373cf5ecd2be7c3e95aecb1c392b4a94c4d8523d
diff --git a/vars/artifactory.groovy b/vars/artifactory.groovy
index 0d443d6..3b17a06 100644
--- a/vars/artifactory.groovy
+++ b/vars/artifactory.groovy
@@ -205,3 +205,34 @@
json = null
return result
}
+
+
+/**
+ * This method returns Artifactory URL for the given server ID
+ *
+ * @param serverId a server ID - server name at resources/../servers
+ * @return Artifactory URL (String)
+ */
+String getArtifactoryUrlByID(String serverId) {
+ Map artConfig = parseJSON(loadResource("artifactory/servers/${serverId}.json"))
+ return artConfig.artifactoryUrl
+}
+
+
+/**
+ * This method generates an upload spec JSON string
+ *
+ * @param artifactoryPath target path in Artifactory repository
+ * @param artifactsPattern file pattern for artifacts to upload
+ * @return JSON string representation of upload spec
+ */
+String getUploadSpec(String artifactoryPath, String artifactsPattern) {
+ return """{
+ "files": [
+ {
+ "pattern": "${artifactsPattern}",
+ "target": "${artifactoryPath}"
+ }
+ ]
+ }"""
+}