forked from seansp-zz/Framework-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
copy_packages_to_azure.ps1
71 lines (59 loc) · 2.06 KB
/
copy_packages_to_azure.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
param (
[Parameter(Mandatory=$false)] [string] $destResourceGroup="smoke_output_resource_group",
[Parameter(Mandatory=$false)] [string] $destAccountName="smoketestoutstorageacct",
[Parameter(Mandatory=$false)] [string] $destContainer="last-build-packages",
[Parameter(Mandatory=$false)] [string] $driveLetter="Z:\",
[Parameter(Mandatory=$false)] [string] $location="westus"
)
$destResourceGroup=$destResourceGroup.Trim()
$destAccountName=$destAccountName.Trim()
$destContainer=$destContainer.Trim()
$driveLetter=$driveLetter.Trim()
$location=$location.Trim()
. "C:\Framework-Scripts\common_functions.ps1"
Write-Host "Copying Linux kernel build artifacts to the cloud..."
login_azure $destResourceGroup $destAccountName $location
$failure_point = "No failure"
$key=Get-AzureRmStorageAccountKey -ResourceGroupName $destResourceGroup -Name $destAccountName
if ($? -eq $false) {
$failure_point="GetKey"
ErrOut($failure_point)
}
New-AzureStorageContext -StorageAccountName $destAccountName -StorageAccountKey $key[0].Value
if ($? -eq $false) {
$failure_point="NewContext"
ErrOut($failure_point)
}
#
# Copy the latest packages up to Azure
$packages=get-childitem -path $driveLetter
Remove-Item -Path C:\temp\file_list -Force
foreach ($package in $packages) {
$package.name | out-file -Append C:\temp\file_list
}
#
# Clear the working container
#
Get-AzureStorageBlob -Container $destContainer -blob * | ForEach-Object {Remove-AzureStorageBlob -Blob $_.Name -Container $destContainer}
if ($? -eq $false) {
$failure_point="ClearingContainers"
ErrOut($failure_point)
}
#
# Copy the kernel packages to Azure.
#
$drive = $driveLetter
Get-ChildItem $drive | Set-AzureStorageBlobContent -Container $destContainer -force
if ($? -eq $false) {
$failure_point="CopyPackages"
ErrOut($failure_point)
}
Write-Host "Copy complete."
exit 0
unction ErrOut([string] $failPoint) {
#
# Not really sure what happened. Better let a human have a look...
#
write-host "Copying packages to Azure has failed in operation $failure_point."
exit 1
}