-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed single file blob upload #7222
Merged
arjgupta
merged 10 commits into
master
from
Microsoft/users/raagra/afc-single-file-upload-fix
May 18, 2018
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c2b7a3e
fixed single file blob upload
rajatagrawal-dev 01245f1
fixed single file blob upload
rajatagrawal-dev 4048e19
Merge branch 'Microsoft/users/raagra/afc-single-file-upload-fix' of h…
rajatagrawal-dev 3ac4832
Merge branch 'Microsoft/users/raagra/afc-single-file-upload-fix' of h…
rajatagrawal-dev 3adbe38
Merge branch 'Microsoft/users/raagra/afc-single-file-upload-fix' of h…
rajatagrawal-dev b320526
Merge branch 'Microsoft/users/raagra/afc-single-file-upload-fix' of h…
rajatagrawal-dev cec4cd5
Merge branch 'Microsoft/users/raagra/afc-single-file-upload-fix' of h…
rajatagrawal-dev b1c9adc
fixed L0
rajatagrawal-dev b145804
clean target issue + pr comments
rajatagrawal-dev 1e0b753
pr feedback
rajatagrawal-dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -247,16 +247,34 @@ function Upload-FilesToAzureContainer | |
{ | ||
Write-Output (Get-VstsLocString -Key "AFC_UploadFilesStorageAccount" -ArgumentList $sourcePath, $storageAccountName, $containerName, $blobPrefix) | ||
|
||
$resolvedSourcePath = $sourcePath | ||
|
||
# Check if source path is a file. If yes, then add /Pattern additional argument. | ||
if(Test-Path -Path $sourcePath -PathType Leaf) | ||
{ | ||
$fileInfo = Get-Item $sourcePath | ||
$resolvedSourcePath = $fileInfo.Directory.FullName | ||
$additionalArguments += " /Pattern:`"$($fileInfo.Name)`"" | ||
} | ||
|
||
$blobPrefix = $blobPrefix.Trim() | ||
$containerURL = [string]::Format("{0}/{1}/{2}", $blobStorageEndpoint.Trim("/"), $containerName, $blobPrefix).Trim("/") | ||
$azCopyExeLocation = Join-Path -Path $azCopyLocation -ChildPath "AzCopy.exe" | ||
|
||
Write-Verbose "Executing command: & `"$azCopyExeLocation`" /Source:$sourcePath /Dest:$containerURL /DestKey:`"*****`" $additionalArguments" | ||
Write-Verbose "Executing command: & `"$azCopyExeLocation`" /Source:`"$resolvedSourcePath`" /Dest:`"$containerURL`" /DestKey:`"*****`" $additionalArguments" | ||
|
||
$uploadToBlobCommand = "& `"$azCopyExeLocation`" /Source:$sourcePath /Dest:$containerURL /DestKey:`"$storageKey`" $additionalArguments" | ||
$uploadToBlobCommand = "& `"$azCopyExeLocation`" /Source:`"$resolvedSourcePath`" /Dest:`"$containerURL`" /DestKey:`"$storageKey`" $additionalArguments" | ||
|
||
Invoke-Expression $uploadToBlobCommand | ||
Write-Output (Get-VstsLocString -Key "AFC_UploadFileSuccessful" -ArgumentList $sourcePath, $storageAccountName, $containerName, $blobPrefix) | ||
|
||
if($LASTEXITCODE -eq 0) | ||
{ | ||
Write-Output (Get-VstsLocString -Key "AFC_UploadFileSuccessful" -ArgumentList $sourcePath, $storageAccountName, $containerName, $blobPrefix) | ||
} | ||
else | ||
{ | ||
throw (Get-VstsLocString -Key "AFC_AzCopyBlobUploadNonZeroExitCode") | ||
} | ||
} | ||
catch | ||
{ | ||
|
@@ -275,16 +293,16 @@ function Upload-FilesToAzureContainer | |
} | ||
finally | ||
{ | ||
Handle-AzCopyLogs -isLogsPresent $useDefaultArguments -logsFilePath $azCopyLogFilePath -ErrorAction SilentlyContinue | ||
Handle-AzCopyLogs -isLogsPresent $useDefaultArguments -logsFilePath "$azCopyLogFilePath" -ErrorAction SilentlyContinue | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit, you do not need to enclose it in double quotes. |
||
} | ||
} | ||
|
||
function Handle-AzCopyLogs | ||
{ | ||
[CmdletBinding()] | ||
param( | ||
[bool]$isLogsPresent, | ||
[string]$logsFilePath | ||
[Nullable[bool]]$isLogsPresent, | ||
[AllowEmptyString()][string]$logsFilePath | ||
) | ||
|
||
if($isLogsPresent) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it will be better if you write this with ##[command] and write it to output and not the verbose stream. Will be better experience. And no need to repeat the command here and in the next line. create it once, and then use it wherever. Later if this command changes, you will need to update at only place.