From f7f9e93fa9d4f870a6af091a6c5c964e0caabb8d Mon Sep 17 00:00:00 2001 From: L2JE Date: Mon, 2 Oct 2023 17:28:59 -0300 Subject: [PATCH 1/4] Allow retrieve execution log files from other paths --- .../plugin/AzureFileStoragePlugin.groovy | 23 ++++++++++++++----- .../plugin/AzureFileStoragePluginSpec.groovy | 15 ++++++++++++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/main/groovy/com/rundeck/plugins/azure/plugin/AzureFileStoragePlugin.groovy b/src/main/groovy/com/rundeck/plugins/azure/plugin/AzureFileStoragePlugin.groovy index 40aebc4..58beaa7 100644 --- a/src/main/groovy/com/rundeck/plugins/azure/plugin/AzureFileStoragePlugin.groovy +++ b/src/main/groovy/com/rundeck/plugins/azure/plugin/AzureFileStoragePlugin.groovy @@ -131,6 +131,10 @@ class AzureFileStoragePlugin implements ExecutionFileStoragePlugin, ExecutionMul container.createIfNotExists() } + protected static boolean isImportedExecution(Map context){ + return context != null && context.get("isRemoteFilePath") != null && context.get("isRemoteFilePath") == "true" + } + @Override boolean isAvailable(String filetype) throws ExecutionFileStorageException { try { @@ -225,7 +229,10 @@ class AzureFileStoragePlugin implements ExecutionFileStoragePlugin, ExecutionMul */ static String expandPath(String pathFormat, Map context) { String result = pathFormat.replaceAll("^/+", ""); - if (null != context) { + + if(isImportedExecution(context)) + result = String.valueOf(context.get("outputfilepath").toString()) + else if (null != context) { result = DataContextUtils.replaceDataReferences( result, DataContextUtils.addContext("job", stringMap(context), new HashMap<>()), @@ -252,12 +259,16 @@ class AzureFileStoragePlugin implements ExecutionFileStoragePlugin, ExecutionMul } String getFileName(String fileType){ - String executionId=context.get(META_EXECID) - String project=context.get(META_PROJECT) - - String fileName="${project}/${executionId}.${fileType}" + String fileName + if(isImportedExecution(this.context)) + fileName = expandedPath.substring(expandedPath.indexOf("/"), expandedPath.length()).toLowerCase() + else{ + String executionId=context.get(META_EXECID) + String project=context.get(META_PROJECT) + fileName = "${project}/${executionId}" + } - return fileName + return fileName + ".${fileType}" } diff --git a/src/test/groovy/com/rundeck/plugins/azure/plugin/AzureFileStoragePluginSpec.groovy b/src/test/groovy/com/rundeck/plugins/azure/plugin/AzureFileStoragePluginSpec.groovy index 75bdf86..bea8c1a 100644 --- a/src/test/groovy/com/rundeck/plugins/azure/plugin/AzureFileStoragePluginSpec.groovy +++ b/src/test/groovy/com/rundeck/plugins/azure/plugin/AzureFileStoragePluginSpec.groovy @@ -53,6 +53,21 @@ class AzureFileStoragePluginSpec extends Specification{ thrown IllegalArgumentException } + def "return true if it was initialized with an imported execution"(){ + when: + boolean isImportedExecution = AzureFileStoragePlugin.isImportedExecution(context) + + then: + isImportedExecution == expected + + where: + context | expected + ['isRemoteFilePath': 'asd'] | false + ['isRemoteFilePath': 'true'] | true + [:] | false + null | false + } + private HashMap testContext() { HashMap stringHashMap = new HashMap(); From 715bca57f72999c7ba7d6fb88859ed057c4d9f40 Mon Sep 17 00:00:00 2001 From: L2JE Date: Tue, 17 Oct 2023 13:51:34 -0300 Subject: [PATCH 2/4] implement getConfiguredPathTemplate to return configured path --- .../plugins/azure/plugin/AzureFileStoragePlugin.groovy | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/groovy/com/rundeck/plugins/azure/plugin/AzureFileStoragePlugin.groovy b/src/main/groovy/com/rundeck/plugins/azure/plugin/AzureFileStoragePlugin.groovy index 58beaa7..b42f048 100644 --- a/src/main/groovy/com/rundeck/plugins/azure/plugin/AzureFileStoragePlugin.groovy +++ b/src/main/groovy/com/rundeck/plugins/azure/plugin/AzureFileStoragePlugin.groovy @@ -310,5 +310,8 @@ class AzureFileStoragePlugin implements ExecutionFileStoragePlugin, ExecutionMul return blob } - + @Override + public String getConfiguredPathTemplate(){ + return this.path; + } } From 0afcd68b7f87a905469fb28f10bb1d07a55b822f Mon Sep 17 00:00:00 2001 From: L2JE Date: Thu, 19 Oct 2023 15:53:01 -0300 Subject: [PATCH 3/4] Added javadoc to isImportedExecution method --- .../plugins/azure/plugin/AzureFileStoragePlugin.groovy | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/groovy/com/rundeck/plugins/azure/plugin/AzureFileStoragePlugin.groovy b/src/main/groovy/com/rundeck/plugins/azure/plugin/AzureFileStoragePlugin.groovy index b42f048..4d5bc44 100644 --- a/src/main/groovy/com/rundeck/plugins/azure/plugin/AzureFileStoragePlugin.groovy +++ b/src/main/groovy/com/rundeck/plugins/azure/plugin/AzureFileStoragePlugin.groovy @@ -131,6 +131,10 @@ class AzureFileStoragePlugin implements ExecutionFileStoragePlugin, ExecutionMul container.createIfNotExists() } + /** + * @param context execution context + * @return true if the given context has the expanded path of the log files in the `outputfilepath` variable + */ protected static boolean isImportedExecution(Map context){ return context != null && context.get("isRemoteFilePath") != null && context.get("isRemoteFilePath") == "true" } From 9f680c905725472ded2cc9791873eea496cb4d21 Mon Sep 17 00:00:00 2001 From: L2JE Date: Wed, 25 Oct 2023 12:11:26 -0300 Subject: [PATCH 4/4] Updated core dependency to 4.17.2-rc1-20231025 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index de57336..d17d505 100644 --- a/build.gradle +++ b/build.gradle @@ -40,7 +40,7 @@ configurations { dependencies { implementation 'org.codehaus.groovy:groovy-all:3.0.9' - implementation group: 'org.rundeck', name: 'rundeck-core', version: '4.3.+' + implementation group: 'org.rundeck', name: 'rundeck-core', version: '4.17.2-rc1-20231025' pluginLibs (group: 'com.microsoft.azure', name: 'azure', version: '1.41.4'){ exclude group: "com.fasterxml.jackson.core"