Skip to content
Permalink
Browse files

Fix AzureBlobAction [FIXED JENKINS-42726]

  • Loading branch information...
clguimanMSFT committed Mar 13, 2017
1 parent da1ee43 commit f8e8b7a22f0b276d6c57be0db2ffe41bfb3b3d36
@@ -1,8 +1,7 @@
package com.microsoftopentechnologies.windowsazurestorage;

import com.microsoftopentechnologies.windowsazurestorage.WAStoragePublisher.WAStorageDescriptor;
import com.microsoftopentechnologies.windowsazurestorage.beans.StorageAccountInfo;
import com.microsoftopentechnologies.windowsazurestorage.helper.Utils;
import com.microsoftopentechnologies.windowsazurestorage.helper.AzureCredentials;
import hudson.model.Api;
import hudson.model.Run;
import hudson.model.RunAction;
@@ -25,16 +24,18 @@
private final boolean allowAnonymousAccess;
private final AzureBlob zipArchiveBlob;
private final List<AzureBlob> individualBlobs;
private final String storageCredentialId;

public AzureBlobAction(Run build, String storageAccountName, String containerName,
List<AzureBlob> individualBlobs, AzureBlob zipArchiveBlob,
boolean allowAnonymousAccess) {
boolean allowAnonymousAccess, String storageCredentialId) {
this.storageAccountName = storageAccountName;
this.containerName = containerName;
this.individualBlobs = individualBlobs;
this.allowAnonymousAccess = allowAnonymousAccess;
this.zipArchiveBlob = zipArchiveBlob;
this.build = build;
this.storageCredentialId = storageCredentialId;
}

public Run<?, ?> getBuild() {
@@ -90,20 +91,16 @@ public boolean getAllowAnonymousAccess() {
return allowAnonymousAccess;
}

private WAStoragePublisher.WAStorageDescriptor getWAStorageDescriptor() {
WAStoragePublisher.WAStorageDescriptor desc = Utils.getJenkinsInstance().getDescriptorByType(WAStoragePublisher.WAStorageDescriptor.class);
return desc;
}

public void doProcessDownloadRequest(final StaplerRequest request, final StaplerResponse response) throws IOException, ServletException {
WAStorageDescriptor storageDesc = getWAStorageDescriptor();
StorageAccountInfo accountInfo = storageDesc.getStorageAccount(storageAccountName);
AzureCredentials.StorageAccountCredential accountCredentials = AzureCredentials.getStorageCreds(storageCredentialId, storageAccountName);

if (accountInfo == null) {
if (accountCredentials == null) {
response.sendError(500, "Azure Storage account global configuration is missing");
return;
}

StorageAccountInfo accountInfo = AzureCredentials.convertToStorageAccountInfo(accountCredentials);

if (!allowAnonymousAccess && isAnonymousAccess(Jenkins.getAuthentication())) {
String url = request.getOriginalRequestURI();
response.sendRedirect("/login?from=" + url);
@@ -333,7 +333,7 @@ public synchronized void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath ws, @
listener.getLogger().println(Messages.WAStoragePublisher_files_uploaded_count(filesUploaded));

run.getActions().add(new AzureBlobAction(run, strAcc.getStorageAccName(),
expContainerName, individualBlobs, zipArchiveBlob, allowAnonymousAccess));
expContainerName, individualBlobs, zipArchiveBlob, allowAnonymousAccess, storageCredentialId));
}
} catch (Exception e) {
e.printStackTrace(listener.error(Messages

0 comments on commit f8e8b7a

Please sign in to comment.
You can’t perform that action at this time.