From 2b4c2c2d63e5386b9a7e678c8a1e3ee476c8b928 Mon Sep 17 00:00:00 2001 From: Minreaux <9372700+Minreaux@users.noreply.github.com> Date: Wed, 13 Dec 2023 12:40:38 -0800 Subject: [PATCH] Add support for Azure CDN endpoint URL (#85) Co-authored-by: Tim Jacomb <21194782+timja@users.noreply.github.com> --- pom.xml | 9 ++++----- .../com/microsoft/jenkins/artifactmanager/Utils.java | 8 +++++++- src/main/resources/index.jelly | 2 +- .../IntegrationTests/IntegrationTest.java | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 4e1ca1c..245c4f1 100644 --- a/pom.xml +++ b/pom.xml @@ -12,11 +12,10 @@ ${changelist} hpi Azure Artifact Manager plugin - A Jenkins plugin to keep artifacts and Pipeline stashes in Azure storage. 999999-SNAPSHOT - 2.361.4 + 2.387.3 @@ -30,8 +29,8 @@ io.jenkins.tools.bom - bom-2.361.x - 2102.v854b_fec19c92 + bom-2.387.x + 2543.vfb_1a_5fb_9496d import pom @@ -42,7 +41,7 @@ org.jenkins-ci.plugins windows-azure-storage - 386.v673495b0a5de + 414.v87922b9c52e2 org.jenkins-ci.plugins.workflow diff --git a/src/main/java/com/microsoft/jenkins/artifactmanager/Utils.java b/src/main/java/com/microsoft/jenkins/artifactmanager/Utils.java index 3cc2413..8d612b6 100644 --- a/src/main/java/com/microsoft/jenkins/artifactmanager/Utils.java +++ b/src/main/java/com/microsoft/jenkins/artifactmanager/Utils.java @@ -102,7 +102,13 @@ public static String getBlobUrl( BlobClient blob = container.getBlobClient(blobName); - return blob.getBlobUrl(); + // Check if CDN endpoint exists and use CDN URL, otherwise use blob URL + String cdnEndpoint = storageAccount.getCdnEndPointURL(); + if (!StringUtils.isBlank(cdnEndpoint)) { + return (cdnEndpoint + "/" + blob.getContainerName() + "/" + blob.getBlobName()); + } else { + return blob.getBlobUrl(); + } } public static String generateBlobSASURL( diff --git a/src/main/resources/index.jelly b/src/main/resources/index.jelly index 63da622..dc3cf53 100644 --- a/src/main/resources/index.jelly +++ b/src/main/resources/index.jelly @@ -1,4 +1,4 @@
- Jenkins Azure artifact manager plugin + Jenkins Azure Artifact Manager plugin enables keeping artifacts and Pipeline stashes in Azure Blob storage.
diff --git a/src/test/java/com/microsoft/jenkins/artifactmanager/IntegrationTests/IntegrationTest.java b/src/test/java/com/microsoft/jenkins/artifactmanager/IntegrationTests/IntegrationTest.java index 1f1f865..ccb51e0 100644 --- a/src/test/java/com/microsoft/jenkins/artifactmanager/IntegrationTests/IntegrationTest.java +++ b/src/test/java/com/microsoft/jenkins/artifactmanager/IntegrationTests/IntegrationTest.java @@ -41,7 +41,7 @@ protected static class TestEnvironment { azureStorageAccountKey2 = TestEnvironment.loadFromEnv("AZURE_STORAGE_TEST_STORAGE_ACCOUNT_KEY2"); blobURL = Utils.DEF_BLOB_URL; - sampleStorageAccount = new StorageAccountInfo(azureStorageAccountName, azureStorageAccountKey1, blobURL); + sampleStorageAccount = new StorageAccountInfo(azureStorageAccountName, azureStorageAccountKey1, blobURL, ""); containerName = name; shareName = name; }