Merge pull request #51 from iamshital/master

Added support to launch test jobs without re-uploading files
This commit is contained in:
Shital Savekar 2018-06-05 13:57:07 -07:00 коммит произвёл GitHub
Родитель a415ccfd76 9053a718fa
Коммит b192bdd6cd
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 287 добавлений и 284 удалений

2
.gitignore поставляемый
Просмотреть файл

@ -1,4 +1,3 @@
XML/AzureSecrets.xml
TestResults*
iamshital.code-workspace
@ -8,3 +7,4 @@ Temp*
report*
UploadStatusFile*
*.azure.env
*-buildlogs.zip

Просмотреть файл

@ -1,12 +1,13 @@
Param (
$RemoteFolder = "J:\ReceivedFiles",
$LocalFolder = "Q:\Temp"
$LocalFolder = "."
)
Get-ChildItem .\Libraries -Recurse | Where-Object { $_.FullName.EndsWith(".psm1") } | ForEach-Object { Import-Module $_.FullName -Force -Global }
$CurrentRemoteFolder = "$RemoteFolder\$env:JenkinsUser"
$CurrentLocalFolder = "$LocalFolder"
$WorkingDirectory = (Get-Location).Path
$ExitCode = 0
try
@ -27,19 +28,17 @@ try
$ExitCode = 1
}
elseif ( $env:CustomKernelFile)
{
if ($env:Kernel -eq "default")
{
LogMsg "Overriding CustomKernelFile."
}
{
if ( ($env:CustomKernelFile).EndsWith(".deb") -or ($env:CustomKernelFile).EndsWith(".rpm") )
{
$ReceivedFile = "$CurrentRemoteFolder\$env:UpstreamBuildNumber-$env:CustomKernelFile"
if (Test-Path $ReceivedFile)
$CurrentKernel = "$CurrentLocalFolder\$env:UpstreamBuildNumber-$env:CustomKernelFile"
$ReceivedKernel = "$CurrentRemoteFolder\$env:CustomKernelFile"
if (Test-Path $ReceivedKernel)
{
$KernelFile = Split-Path $ReceivedFile -Leaf
LogMsg "Copying $ReceivedFile --> $CurrentLocalFolder."
$out = Copy-Item -Path $ReceivedFile -Destination "$KernelFile" -Force
LogMsg "Copying $ReceivedKernel --> $CurrentKernel for current use..."
$out = Copy-Item -Path $ReceivedKernel -Destination "$CurrentKernel" -Force
$KernelFile = Split-Path $CurrentKernel -Leaf
LogMsg "Saving $KernelFile to CustomKernel.azure.env"
$out = Set-Content -Value "$KernelFile" -Path CustomKernel.azure.env -Force -NoNewline
$ExitCode = 0
@ -47,7 +46,7 @@ try
else
{
$ExitCode = 1
LogError "$ReceivedFile is not present. Did you forgot to upload it?"
LogError "$ReceivedKernel is not present. Did you forgot to upload it?"
}
}
else
@ -59,48 +58,73 @@ try
}
elseif ( $env:CustomKernelURL )
{
if ($env:Kernel -eq "default")
if ( ($env:CustomKernelURL).EndsWith(".deb") -or ($env:CustomKernelURL).EndsWith(".rpm") )
{
LogMsg "Overriding CustomKernelURL."
}
$DestinationFile = "$(Split-Path -Path $env:CustomKernelURL -Leaf)"
Import-Module BitsTransfer -Force
$WorkingDirectory = (Get-Location).Path
LogMsg "Downloading $env:CustomKernelURL to '$WorkingDirectory\$DestinationFile'"
$DownloadJob = Start-BitsTransfer -Source "$env:CustomKernelURL" -Asynchronous -Destination "$WorkingDirectory\$DestinationFile" -TransferPolicy Unrestricted -TransferType Download -Priority High
$DownloadJobStatus = Get-BitsTransfer -JobId $DownloadJob.JobId
Start-Sleep -Seconds 1
LogMsg "JobID: $($DownloadJob.JobId)"
while ($DownloadJobStatus.JobState -eq "Connecting" -or $DownloadJobStatus.JobState -eq "Transferring" -or $DownloadJobStatus.JobState -eq "Queued" )
{
$DownloadProgress = 100 - ((($DownloadJobStatus.BytesTotal - $DownloadJobStatus.BytesTransferred) / $DownloadJobStatus.BytesTotal) * 100)
$DownloadProgress = [math]::Round($DownloadProgress,2)
LogMsg "Download '$($DownloadJobStatus.JobState)': $DownloadProgress%"
Start-Sleep -Seconds 2
}
if ($DownloadJobStatus.JobState -eq "Transferred")
{
LogMsg "Finalizing downloaded file..."
Complete-BitsTransfer -BitsJob $DownloadJob
LogMsg "Download progress: Completed"
$SourceKernelName = "$(Split-Path -Path $env:CustomKernelURL -Leaf)"
$CurrentKernel = "$CurrentLocalFolder\$env:UpstreamBuildNumber-$SourceKernelName"
$ReceivedKernel = "$CurrentRemoteFolder\$SourceKernelName"
if (Test-Path $ReceivedKernel)
{
LogMsg "$SourceKernelName File was already downloaded."
LogMsg "Copying $ReceivedKernel --> $CurrentKernel for current use..."
Copy-Item -Path "$ReceivedKernel" -Destination $CurrentKernel -Force
$KernelFile = $CurrentKernel | Split-Path -Leaf
LogMsg "Saving $KernelFile to CustomKernel.azure.env"
$out = Set-Content -Value "$KernelFile" -Path CustomKernel.azure.env -Force -NoNewline
$ExitCode = 0
}
else
{
#Import down module.
Import-Module BitsTransfer -Force
LogMsg "Downloading $env:CustomKernelURL to '$CurrentLocalFolder\$SourceKernelName'"
$DownloadJob = Start-BitsTransfer -Source "$env:CustomKernelURL" -Asynchronous -Destination "$CurrentLocalFolder\$SourceKernelName" -TransferPolicy Unrestricted -TransferType Download -Priority High
$DownloadJobStatus = Get-BitsTransfer -JobId $DownloadJob.JobId
Start-Sleep -Seconds 1
LogMsg "JobID: $($DownloadJob.JobId)"
while ($DownloadJobStatus.JobState -eq "Connecting" -or $DownloadJobStatus.JobState -eq "Transferring" -or $DownloadJobStatus.JobState -eq "Queued" )
{
$DownloadProgress = 100 - ((($DownloadJobStatus.BytesTotal - $DownloadJobStatus.BytesTransferred) / $DownloadJobStatus.BytesTotal) * 100)
$DownloadProgress = [math]::Round($DownloadProgress,2)
LogMsg "Download '$($DownloadJobStatus.JobState)': $DownloadProgress%"
Start-Sleep -Seconds 2
}
if ($DownloadJobStatus.JobState -eq "Transferred")
{
LogMsg "Finalizing downloaded file..."
Complete-BitsTransfer -BitsJob $DownloadJob
LogMsg "Download progress: Completed"
}
else
{
LogMsg "Download status : $($DownloadJobStatus.JobState)"
}
if (Test-Path "$CurrentLocalFolder\$SourceKernelName")
{
LogMsg "Copying $CurrentLocalFolder\$SourceKernelName --> $ReceivedKernel for future use..."
Copy-Item -Path "$CurrentLocalFolder\$SourceKernelName" -Destination $ReceivedKernel -Force
LogMsg "Moving $CurrentLocalFolder\$SourceKernelName --> $CurrentKernel for current use..."
Move-Item -Path "$CurrentLocalFolder\$SourceKernelName" -Destination $CurrentKernel -Force
$KernelFile = $CurrentKernel | Split-Path -Leaf
LogMsg "Saving $KernelFile to CustomKernel.azure.env"
$out = Set-Content -Value "$KernelFile" -Path CustomKernel.azure.env -Force -NoNewline
$ExitCode = 0
}
else
{
$ExitCode = 1
LogError "$SourceKernelName is not present. Is the CustomKernelURL a valid link?"
}
}
}
else
{
LogMsg "Download status : $($DownloadJobStatus.JobState)"
}
if (Test-Path $DestinationFile)
{
$KernelFile = "$env:UpstreamBuildNumber-$DestinationFile"
LogMsg "Renaming $DestinationFile --> $KernelFile."
$Out = Rename-Item -Path $DestinationFile -NewName $KernelFile
LogMsg "Saving $KernelFile to CustomKernel.azure.env"
$out = Set-Content -Value "$KernelFile" -Path CustomKernel.azure.env -Force -NoNewline
$ExitCode = 0
}
else
{
$ExitCode = 1
LogError "$DestinationFile is not present. Is the CustomKernelURL a valid link?"
$FileExtension = [System.IO.Path]::GetExtension("$env:CustomKernelFile")
LogError "Unsupported file type: *$FileExtension"
$ExitCode += 1
}
}
else

Просмотреть файл

@ -19,134 +19,168 @@ try
New-Item -Path $CurrentLocalFolder -ItemType Directory -Force | Out-Null
}
LogMsg "Directory : $CurrentLocalFolder is available."
$WorkingDirectory = (Get-Location).Path
#region VALIDATE ARGUMENTS
if ( $env:CustomVHD -or $env:CustomVHDURL)
{
if ( $env:CustomVHDURL )
{
$DestinationFile = "$(Split-Path -Path $env:CustomVHDURL -Leaf)"
Import-Module BitsTransfer -Force
$WorkingDirectory = (Get-Location).Path
LogMsg "Downloading $env:CustomVHDURL to '$WorkingDirectory\$DestinationFile'"
$DownloadJob = Start-BitsTransfer -Source "$env:CustomVHDURL" -Asynchronous -Destination "$WorkingDirectory\$DestinationFile" -TransferPolicy Unrestricted -TransferType Download -Priority High
$DownloadJobStatus = Get-BitsTransfer -JobId $DownloadJob.JobId
Start-Sleep -Seconds 1
LogMsg "JobID: $($DownloadJob.JobId)"
while ($DownloadJobStatus.JobState -eq "Connecting" -or $DownloadJobStatus.JobState -eq "Transferring" -or $DownloadJobStatus.JobState -eq "Queued" )
$SourceVHDName = "$(Split-Path -Path $env:CustomVHDURL -Leaf)"
$CurrentVHD = "$LocalFolder\$env:UpstreamBuildNumber-$SourceVHDName"
$ReceivedVHD = "$CurrentRemoteFolder\$SourceVHDName"
if (Test-Path $ReceivedVHD)
{
$DownloadProgress = 100 - ((($DownloadJobStatus.BytesTotal - $DownloadJobStatus.BytesTransferred) / $DownloadJobStatus.BytesTotal) * 100)
$DownloadProgress = [math]::Round($DownloadProgress,2)
LogMsg "Download '$($DownloadJobStatus.JobState)': $DownloadProgress%"
Start-Sleep -Seconds 2
}
if ($DownloadJobStatus.JobState -eq "Transferred")
{
LogMsg "Finalizing downloaded file..."
Complete-BitsTransfer -BitsJob $DownloadJob
}
else
{
LogMsg "Download status : $($DownloadJobStatus.JobState)"
}
if (Test-Path $DestinationFile)
{
$CurrentVHD = $DestinationFile
Rename-Item -Path $CurrentVHD -NewName "$env:UpstreamBuildNumber-$CurrentVHD" -Verbose
LogMsg "Download progress: Completed"
LogMsg "$SourceVHDName File was already downloaded."
LogMsg "Copying $ReceivedVHD --> $CurrentVHD..."
Copy-Item -Path $ReceivedVHD -Destination $CurrentVHD -Force
LogMsg "Copy Completed."
}
else
{
$ExitCode = 1
LogError "$DestinationFile is not present. Is the CustomVHDURL a valid link?"
LogMsg "$CurrentVHD file not present locally."
Import-Module BitsTransfer -Force
#Region Download the VHD.
LogMsg "Downloading $env:CustomVHDURL to '$LocalFolder\$SourceVHDName'"
$DownloadJob = Start-BitsTransfer -Source "$env:CustomVHDURL" -Asynchronous -Destination "$LocalFolder\$SourceVHDName" -TransferPolicy Unrestricted -TransferType Download -Priority High
$DownloadJobStatus = Get-BitsTransfer -JobId $DownloadJob.JobId
Start-Sleep -Seconds 1
LogMsg "JobID: $($DownloadJob.JobId)"
while ($DownloadJobStatus.JobState -eq "Connecting" -or $DownloadJobStatus.JobState -eq "Transferring" -or $DownloadJobStatus.JobState -eq "Queued" )
{
$DownloadProgress = 100 - ((($DownloadJobStatus.BytesTotal - $DownloadJobStatus.BytesTransferred) / $DownloadJobStatus.BytesTotal) * 100)
$DownloadProgress = [math]::Round($DownloadProgress,2)
LogMsg "Download '$($DownloadJobStatus.JobState)': $DownloadProgress%"
Start-Sleep -Seconds 2
}
if ($DownloadJobStatus.JobState -eq "Transferred")
{
LogMsg "Finalizing downloaded file..."
Complete-BitsTransfer -BitsJob $DownloadJob
}
else
{
LogMsg "Download status : $($DownloadJobStatus.JobState)"
}
#endregion
if (Test-Path "$LocalFolder\$SourceVHDName")
{
LogMsg "Download progress: Completed"
#Copy VHD to remote received files -
LogMsg "Copying $SourceVHDName --> $ReceivedVHD for future use."
Copy-Item -Path $LocalFolder\$SourceVHDName -Destination $ReceivedVHD -Force
#Move VHD to Local Temp Folder.
LogMsg "Moving $SourceVHDName --> $CurrentVHD for current use."
Move-Item -Path $LocalFolder\$SourceVHDName -Destination $CurrentVHD -Force
}
else
{
$ExitCode += 1
LogError "$SourceVHDName is not present. Is the CustomVHDURL a valid link?"
}
}
}
else
{
$CurrentVHD = $env:CustomVHD
$SourceVHDName = $env:CustomVHD
$CurrentVHD = "$LocalFolder\$env:UpstreamBuildNumber-$SourceVHDName"
$ReceivedVHD = "$CurrentRemoteFolder\$SourceVHDName"
if (Test-Path $ReceivedVHD)
{
LogMsg "$SourceVHDName File was present in local storage."
LogMsg "Copying $ReceivedVHD --> $CurrentVHD for current use.."
Copy-Item -Path $ReceivedVHD -Destination $CurrentVHD -Force
LogMsg "Copy Completed."
}
else
{
LogMsg "We're not able to find $ReceivedVHD. Did uploade went successful?"
$ExitCode += 1
}
}
if ( ($CurrentVHD).EndsWith(".xz") -or ($CurrentVHD).EndsWith(".vhd") -or ($CurrentVHD).EndsWith(".vhdx"))
if ( Test-Path $CurrentVHD)
{
$ReceivedFile = "$env:UpstreamBuildNumber-$CurrentVHD"
if ($env:CustomVHDURL)
if ( ($CurrentVHD).EndsWith(".xz") -or ($CurrentVHD).EndsWith(".vhd") -or ($CurrentVHD).EndsWith(".vhdx"))
{
LogMsg "Moving downloaded $ReceivedFile --> $CurrentLocalFolder."
$Out = Move-Item -Path $ReceivedFile -Destination $CurrentLocalFolder -Force
#region Extract the VHD if required.
if ($CurrentVHD.EndsWith(".xz"))
{
$FilenameToExtract = $CurrentVHD | Split-Path -Leaf
Set-Location $CurrentLocalFolder
LogMsg "Detected *.xz file."
LogMsg "Extracting '$FilenameToExtract'. Please wait..."
$7zConsoleOuput = Invoke-Expression -Command "$7zExePath -y x '$FilenameToExtract';" -Verbose
if ($7zConsoleOuput -imatch "Everything is Ok")
{
LogMsg "Extraction completed."
$CurrentVHD = $CurrentVHD.TrimEnd("xz").TrimEnd(".")
LogMsg "Changing working directory to $WorkingDirectory"
Set-Location $WorkingDirectory
$VhdActualSize = ($7zConsoleOuput -imatch "size").Replace(" ",'').Replace(" ",'').Replace(" ",'').Replace(" ",'').Split(":")[1]
$VhdCompressedSize = ($7zConsoleOuput -imatch "Compressed").Replace(" ",'').Replace(" ",'').Replace(" ",'').Replace(" ",'').Split(":")[1]
$CompressinRatio = ((($VhdCompressedSize/($VhdActualSize-$VhdCompressedSize))*100))
LogMsg "Compression Ratio : $([math]::Round($CompressinRatio,2))%"
}
else
{
$ExitCode += 1
ThrowException "Failed to extract $FilenameToExtract."
}
}
#endregion
if ($CurrentVHD.EndsWith(".vhdx"))
{
Set-Location $CurrentLocalFolder
$vhdx = $CurrentVHD | Split-Path -Leaf
$vhd = $vhdx.TrimEnd("x")
LogMsg "Converting '$vhdx' --> '$vhd'. [VHDx to VHD]"
$convertJob = Start-Job -ScriptBlock { Convert-VHD -Path $args[0] -DestinationPath $args[1] -VHDType Dynamic } -ArgumentList "$CurrentLocalFolder\$vhdx", "$CurrentLocalFolder\$vhd"
while ($convertJob.State -eq "Running")
{
LogMsg "'$vhdx' --> '$vhd' is running"
Start-Sleep -Seconds 10
}
if ( $convertJob.State -eq "Completed")
{
LogMsg "$CurrentVHD Created suceessfully."
$CurrentVHD = $CurrentVHD.TrimEnd("x")
LogMsg "'$vhdx' --> '$vhd' is Succeeded."
LogMsg "Removing '$vhdx'..."
Remove-Item "$CurrentLocalFolder\$vhdx" -Force -ErrorAction SilentlyContinue
}
else
{
LogMsg "'$vhdx' --> '$vhd' is Failed."
$ExitCode += 1
}
Set-Location $WorkingDirectory
}
ValidateVHD -vhdPath $CurrentVHD
Set-Content -Value "$($CurrentVHD | Split-Path -Leaf)" -Path .\CustomVHD.azure.env -NoNewline -Force
}
else
{
LogMsg "Copying received $ReceivedFile --> $CurrentLocalFolder."
Copy-Item -Path "$CurrentRemoteFolder\$ReceivedFile" -Destination "$CurrentLocalFolder\$ReceivedFile" -Force
$FileExtension = [System.IO.Path]::GetExtension("$CurrentVHD")
LogError "Unsupported file type: *$FileExtension"
$ExitCode += 1
}
if ($ReceivedFile.EndsWith(".xz"))
{
$WorkingDirectory = (Get-Location).Path
Set-Location $CurrentLocalFolder
LogMsg "Detected *.xz file."
LogMsg "Extracting '$ReceivedFile'. Please wait..."
$7zConsoleOuput = Invoke-Expression -Command "$7zExePath -y x '$ReceivedFile';" -Verbose
if ($7zConsoleOuput -imatch "Everything is Ok")
{
LogMsg "Extraction completed."
$NewVHDName = $(($ReceivedFile).TrimEnd("xz").TrimEnd("."))
LogMsg "Changing working directory to $WorkingDirectory"
Set-Location $WorkingDirectory
$VhdActualSize = ($7zConsoleOuput -imatch "size").Replace(" ",'').Replace(" ",'').Replace(" ",'').Replace(" ",'').Split(":")[1]
$VhdCompressedSize = ($7zConsoleOuput -imatch "Compressed").Replace(" ",'').Replace(" ",'').Replace(" ",'').Replace(" ",'').Split(":")[1]
$CompressinRatio = ((($VhdCompressedSize/($VhdActualSize-$VhdCompressedSize))*100))
LogMsg "Compression Ratio : $([math]::Round($CompressinRatio,2))%"
}
else
{
$ExitCode += 1
ThrowException "Failed to extract $ReceivedFile."
}
}
else
{
$NewVHDName = $ReceivedFile
}
if ($NewVHDName.EndsWith(".vhdx"))
{
$WorkingDirectory = $pwd
Set-Location $CurrentLocalFolder
$NewVHDxName = $NewVHDName
$NewVHDName = $NewVHDxName.Replace(".vhdx",".vhd")
LogMsg "Converting '$NewVHDxName' --> '$NewVHDName'. [VHDx to VHD]"
$convertJob = Start-Job -ScriptBlock { Convert-VHD -Path $args[0] -DestinationPath $args[1] -VHDType Dynamic } -ArgumentList "$CurrentLocalFolder\$NewVHDxName", "$CurrentLocalFolder\$NewVHDName"
while ($convertJob.State -eq "Running")
{
LogMsg "'$NewVHDxName' --> '$NewVHDName' is running"
Start-Sleep -Seconds 10
}
if ( $convertJob.State -eq "Completed")
{
LogMsg "'$NewVHDxName' --> '$NewVHDName' is Succeeded."
$ExitCode = 0
LogMsg "Removing '$NewVHDxName'..."
Remove-Item "$CurrentLocalFolder\$NewVHDxName" -Force -ErrorAction SilentlyContinue
}
else
{
LogMsg "'$NewVHDxName' --> '$NewVHDName' is Failed."
$ExitCode += 1
}
Set-Location $WorkingDirectory
}
ValidateVHD -vhdPath "$CurrentLocalFolder\$NewVHDName"
Set-Content -Value "$NewVHDName" -Path .\CustomVHD.azure.env -NoNewline -Force
}
else
{
$FileExtension = [System.IO.Path]::GetExtension("$CurrentVHD")
LogError "Unsupported file type: *$FileExtension"
$ExitCode += 1
LogError "$CurrentVHD is not found. Exiting."
$ExitCode = 1
}
}
else
{
LogError "Did you forgot to provide value for 'CustomVHD' parameter?"
$ExitCode = 1
$ExitCode += 1
}
}
catch

Просмотреть файл

@ -11,8 +11,6 @@ Import-Module BitsTransfer -Force
$BuildNumber = $env:BUILD_NUMBER
$ExitCode = 0
$BuildNumber
$PartnerUsernameShareDirectory = "$SharedParentDirectory\$PartnerUsername"
@ -85,18 +83,9 @@ if ($env:Kernel -eq "custom")
}
else
{
if ($env:CustomKernelFile.EndsWith(".deb"))
{
$TestKernel = "$BuildNumber-$env:CustomKernelFile"
LogMsg "Renaming CustomKernelFile --> $TestKernel"
Rename-Item -Path CustomKernelFile -NewName $TestKernel
}
if ($env:CustomKernelFile.EndsWith(".rpm"))
{
$TestKernel = "$BuildNumber-$env:CustomKernelFile"
LogMsg "Renaming CustomKernelFile --> $TestKernel"
Rename-Item -Path CustomKernelFile -NewName $TestKernel
}
$TestKernel = "$env:CustomKernelFile"
LogMsg "Renaming CustomKernelFile --> $TestKernel"
Rename-Item -Path CustomKernelFile -NewName $TestKernel
}
}
if ($env:customKernelURL)
@ -109,48 +98,12 @@ if ($env:Kernel -eq "custom")
$ExitCode += 1
exit $ExitCode
}
else
{
LogMsg "Downloading $($env:customKernelURL)"
$out = Start-BitsTransfer -Source "$env:customKernelURL"
if ($?)
{
if ($env:customKernelURL.EndsWith(".deb"))
{
$TestKernel = "$BuildNumber-$($env:customKernelURL.Split("/")[$env:customKernelURL.Split("/").Count -1])"
LogMsg "Renaming $($env:customKernelURL.Split("/")[$env:customKernelURL.Split("/").Count -1]) --> $TestKernel"
Rename-Item -Path $($env:customKernelURL.Split("/")[$env:customKernelURL.Split("/").Count -1]) -NewName $TestKernel
}
if ($env:customKernelURL.EndsWith(".rpm"))
{
$TestKernel = "$BuildNumber-$($env:customKernelURL.Split("/")[$env:customKernelURL.Split("/").Count -1])"
LogMsg "Renaming $($env:customKernelURL.Split("/")[$env:customKernelURL.Split("/").Count -1]) --> $TestKernel"
Rename-Item -Path $($env:customKernelURL.Split("/")[$env:customKernelURL.Split("/").Count -1]) -NewName $TestKernel
}
}
else
{
LogMsg "--------------------------------------------------------------------------------------------------------------"
LogMsg "ERROR: Failed to download $($env:customKernelURL). Please verify that your URL is accessible on public internet."
LogMsg "--------------------------------------------------------------------------------------------------------------"
$ExitCode += 1
exit $ExitCode
}
}
}
}
#$PartnerUsernameShareDirectory = "$SharedParentDirectory\$PartnerName-files"
#$out = mkdir "$SharedParentDirectory\$PartnerName-files" -ErrorAction SilentlyContinue | Out-Null
if ($TestKernel)
{
#$out = Start-BitsTransfer -Source "https://github.com/iamshital/azure-linux-automation/raw/master/AddAzureRmAccountFromSecretsFile.ps1"
#$out = Start-BitsTransfer -Source "https://github.com/iamshital/azure-linux-automation/raw/master/Extras/UploadFilesToStorageAccount.ps1"
#.\UploadFilesToStorageAccount.ps1 -filePaths $TestKernel -destinationStorageAccount konkasoftpackages -destinationContainer partner -destinationFolder $PartnerName
LogMsg "Copying $TestKernel --> $PartnerUsernameShareDirectory\$TestKernel"
LogMsg "Moving $TestKernel --> $PartnerUsernameShareDirectory\$TestKernel"
Move-Item $TestKernel $PartnerUsernameShareDirectory\$TestKernel -Force
}
if ($env:CustomVHD)
{
@ -158,10 +111,8 @@ if ($env:CustomVHD)
$TempVHD = ($env:CustomVHD).ToLower()
if ( $TempVHD.EndsWith(".vhd") -or $TempVHD.EndsWith(".vhdx") -or $TempVHD.EndsWith(".xz"))
{
LogMsg "Copying '$env:CustomVHD' --> $PartnerUsernameShareDirectory\$BuildNumber-$env:CustomVHD"
Move-Item CustomVHD $PartnerUsernameShareDirectory\$BuildNumber-$env:CustomVHD -Force
LogMsg "Moving '$env:CustomVHD' --> $PartnerUsernameShareDirectory\$env:CustomVHD"
Move-Item CustomVHD $PartnerUsernameShareDirectory\$env:CustomVHD -Force
$ExitCode = 0
}
else

Просмотреть файл

@ -6,7 +6,7 @@
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
.DESCRIPTION
This script authenticates PS sessing using Azure principal account.
This script checks contents of the ./report/*-junit.xml files and exit with zero or non-zero exit code.
.PARAMETER

Просмотреть файл

@ -67,49 +67,31 @@ else
fi
if ([[ ! $CustomVHD == "" ]] || [[ ! -z $CustomVHD ]]);
then
VHDName=$(basename $CustomVHD)
if ([[ -f $CustomVHD ]]);
then
VHDName=$(basename $CustomVHD)
EncodedVHDName="${UpstreamBuildNumber}-${VHDName}"
#echo "CustomVHD '${VHDName}' encoded to '${EncodedVHDName}'"
LogMsg "Local file ${CustomVHD} available. It will be uploaded."
else
echo "CustomVHD '${CustomVHD}' does not exists. Please verify path."
ExitCode=$(( ExitCode + 1 ))
LogMsg "No local file ${CustomVHD}. Assume it exists in ftp server."
fi
fi
fi
if [[ $Kernel == "" ]] || [[ -z $Kernel ]];
then
LogMsg "Kernel parameter is required"
LogMsg "Kernel parameter is required."
ExitCode=$(( ExitCode + 1 ))
else
if [[ $Kernel == "custom" ]];
then
if [[ ! $CustomKernelFile == "" ]] || [[ ! -z $CustomKernelFile ]];
then
KernelName=$(basename $CustomKernelFile)
if ([[ -f $CustomKernelFile ]]);
then
KernelName=$(basename $CustomKernelFile)
EncodedKernelName="${UpstreamBuildNumber}-${KernelName}"
#echo "CustomKernelFile '${KernelName}' encoded to '${EncodedKernelName}'"
LogMsg "Local file ${CustomKernelFile} available. It will be uploaded."
else
echo "CustomKernelFile '${CustomKernelFile}' does not exists. Please verify path."
ExitCode=$(( ExitCode + 1 ))
LogMsg "No local file ${CustomKernelFile}. Assume it exists in ftp server."
fi
elif [[ ! $CustomKernelURL == "" ]] || [[ ! -z $CustomKernelURL ]];
then
KernelName=$(basename $CustomKernelURL)
rm -rf $KernelName
LogMsg "Downloading $CustomKernelURL"
wget $CustomKernelURL
if [[ "$?" == "0" ]];then
EncodedKernelName="${UpstreamBuildNumber}-${KernelName}"
#echo "CustomKernelFile '${KernelName}' encoded to '${EncodedKernelName}'"
else
LogMsg "Failed."
ExitCode=$(( ExitCode + 1 ))
fi
fi
fi
fi
@ -177,8 +159,11 @@ then
RemoteTriggerURL="${RemoteTriggerURL}&ImageSource=${URLEncodedImageSource}"
elif ([[ ! $CustomVHD == "" ]] || [[ ! -z $CustomVHD ]]);
then
LogMsg "Uploading ${CustomVHD} with name ${EncodedVHDName}..."
curl -T $CustomVHD ftp://${JenkinsURL} --user ${FtpUsername}:${FtpPassword} -Q "-RNFR ${VHDName}" -Q "-RNTO ${EncodedVHDName}"
if ([[ -f $CustomVHD ]]);
then
LogMsg "Uploading ${CustomVHD}..."
curl -T $CustomVHD ftp://${JenkinsURL} --user ${FtpUsername}:${FtpPassword}
fi
RemoteTriggerURL="${RemoteTriggerURL}&CustomVHD=${VHDName}"
elif ([[ ! $CustomVHDURL == "" ]] || [[ ! -z $CustomVHDURL ]]);
then
@ -189,16 +174,18 @@ fi
RemoteTriggerURL="${RemoteTriggerURL}&Kernel=${Kernel}"
if [[ $Kernel == 'custom' ]];
then
if ([[ ! $CustomKernelFile == "" ]] || [[ ! -z $CustomKernelFile ]]) || ([[ ! $CustomKernelURL == "" ]] || [[ ! -z $CustomKernelURL ]]);
if ([[ ! $CustomKernelFile == "" ]] || [[ ! -z $CustomKernelFile ]]);
then
LogMsg "Uploading ${KernelName} with name ${EncodedKernelName}..."
curl -T $KernelName ftp://${JenkinsURL} --user ${FtpUsername}:${FtpPassword} -Q "-RNFR ${KernelName}" -Q "-RNTO ${EncodedKernelName}"
if ([[ ! $CustomKernelFile == "" ]] || [[ ! -z $CustomKernelFile ]]);then
RemoteTriggerURL="${RemoteTriggerURL}&CustomKernelFile=${KernelName}"
elif ([[ ! $CustomKernelURL == "" ]] || [[ ! -z $CustomKernelURL ]]);then
RemoteTriggerURL="${RemoteTriggerURL}&CustomKernelURL=${CustomKernelURL}"
if [[ -f $CustomKernelFile ]];
then
LogMsg "Uploading ${KernelName}..."
curl -T $KernelName ftp://${JenkinsURL} --user ${FtpUsername}:${FtpPassword}
fi
fi
RemoteTriggerURL="${RemoteTriggerURL}&CustomKernelFile=${KernelName}"
elif ([[ ! $CustomKernelURL == "" ]] || [[ ! -z $CustomKernelURL ]]);
then
RemoteTriggerURL="${RemoteTriggerURL}&CustomKernelURL=${CustomKernelURL}"
fi
fi
RemoteTriggerURL="${RemoteTriggerURL}&GitUrlForAutomation=${GitUrlForAutomation}&GitBranchForAutomation=${GitBranchForAutomation}"
@ -223,50 +210,57 @@ fi
RemoteTriggerURL="${RemoteTriggerURL}&Email=${EncodedEmail}"
RemoteQueryURL="https://${JenkinsUser}:${ApiToken}@${JenkinsURL}/job/${TestPipeline}/lastBuild/api/xml"
#echo ${RemoteTriggerURL}
LogMsg "Triggering job..."
curl --silent -X POST ${RemoteTriggerURL}
if [[ "$?" == "0" ]];
then
LogMsg "Job triggered successfully."
if [[ ! -f ./jq ]];
then
LogMsg "Downloading json parser"
curl --silent -O https://raw.githubusercontent.com/LIS/LISAv2/master/Tools/jq
chmod +x jq
fi
BuildNumber=$(curl --silent -X GET "https://${JenkinsUser}:${ApiToken}@${JenkinsURL}/job/${TestPipeline}/lastBuild/api/json" | ./jq '.id' | sed 's/"//g')
BuildURL=$(curl --silent -X GET "https://${JenkinsUser}:${ApiToken}@${JenkinsURL}/job/${TestPipeline}/${BuildNumber}/api/json" | ./jq '.url' | sed 's/"//g')
BuildState=$(curl --silent -X GET "https://${JenkinsUser}:${ApiToken}@${JenkinsURL}/job/${TestPipeline}/${BuildNumber}/api/json" | ./jq '.building' | sed 's/"//g')
BuildResult=$(curl --silent -X GET "https://${JenkinsUser}:${ApiToken}@${JenkinsURL}/job/${TestPipeline}/${BuildNumber}/api/json" | ./jq '.result' | sed 's/"//g')
BlueOceanURL="https://${JenkinsURL}/blue/organizations/jenkins/${TestPipeline}/detail/${TestPipeline}/${BuildNumber}/pipeline"
LogMsg "--------------------------------------"
LogMsg "BuildURL (BlueOcean) : ${BlueOceanURL}"
LogMsg "--------------------------------------"
LogMsg "BuildURL (Classic) : ${BuildURL}console"
LogMsg "--------------------------------------"
if [[ $WaitForResult == "yes" ]];
if [[ "$ExitCode" == "0" ]];
then
LogMsg "Triggering job..."
curl --silent -X POST ${RemoteTriggerURL}
if [[ "$?" == "0" ]];
then
while [[ "$BuildState" == "true" ]]
do
BuildState=$(curl --silent -X GET "https://${JenkinsUser}:${ApiToken}@${JenkinsURL}/job/${TestPipeline}/${BuildNumber}/api/json" | ./jq '.building' | sed 's/"//g')
LogMsg "Current state : Running."
sleep 5
done
BuildResult=$(curl --silent -X GET "https://${JenkinsUser}:${ApiToken}@${JenkinsURL}/job/${TestPipeline}/${BuildNumber}/api/json" | ./jq '.result' | sed 's/"//g')
if [[ "$BuildResult" == "SUCCESS" ]];
LogMsg "Job triggered successfully."
if [[ ! -f ./jq ]];
then
LogMsg "Current State : Completed."
LogMsg "Result: SUCCESS."
exit 0
LogMsg "Downloading json parser"
curl --silent -O https://raw.githubusercontent.com/LIS/LISAv2/master/Tools/jq
chmod +x jq
fi
BuildNumber=$(curl --silent -X GET "https://${JenkinsUser}:${ApiToken}@${JenkinsURL}/job/${TestPipeline}/lastBuild/api/json" | ./jq '.id' | sed 's/"//g')
BuildURL=$(curl --silent -X GET "https://${JenkinsUser}:${ApiToken}@${JenkinsURL}/job/${TestPipeline}/${BuildNumber}/api/json" | ./jq '.url' | sed 's/"//g')
BuildState=$(curl --silent -X GET "https://${JenkinsUser}:${ApiToken}@${JenkinsURL}/job/${TestPipeline}/${BuildNumber}/api/json" | ./jq '.building' | sed 's/"//g')
BuildResult=$(curl --silent -X GET "https://${JenkinsUser}:${ApiToken}@${JenkinsURL}/job/${TestPipeline}/${BuildNumber}/api/json" | ./jq '.result' | sed 's/"//g')
BlueOceanURL="https://${JenkinsURL}/blue/organizations/jenkins/${TestPipeline}/detail/${TestPipeline}/${BuildNumber}/pipeline"
LogMsg "--------------------------------------"
LogMsg "BuildURL (BlueOcean) : ${BlueOceanURL}"
LogMsg "--------------------------------------"
LogMsg "BuildURL (Classic) : ${BuildURL}console"
LogMsg "--------------------------------------"
if [[ $WaitForResult == "yes" ]];
then
while [[ "$BuildState" == "true" ]]
do
BuildState=$(curl --silent -X GET "https://${JenkinsUser}:${ApiToken}@${JenkinsURL}/job/${TestPipeline}/${BuildNumber}/api/json" | ./jq '.building' | sed 's/"//g')
LogMsg "Current state : Running."
sleep 5
done
BuildResult=$(curl --silent -X GET "https://${JenkinsUser}:${ApiToken}@${JenkinsURL}/job/${TestPipeline}/${BuildNumber}/api/json" | ./jq '.result' | sed 's/"//g')
if [[ "$BuildResult" == "SUCCESS" ]];
then
LogMsg "Current State : Completed."
LogMsg "Result: SUCCESS."
exit 0
else
LogMsg "Result: ${BuildResult}"
exit 1
fi
else
LogMsg "Result: ${BuildResult}"
exit 1
exit 0
fi
else
exit 0
LogMsg "Failed to trigger job."
exit 1
fi
else
LogMsg "Failed to trigger job."
LogMsg "Found ${ExitCode} errors. Exiting without launching tests."
exit 1
fi

Просмотреть файл

@ -71,6 +71,6 @@ LinuxPassword=""
TestPipeline=""
#Example TestPipeline="<PatnerName>-Test-Execution-Pipeline"
#Optinal. (Keep the polling enabled after build job is triggered and exit with final result.)
#Optional. (Keep the polling enabled after build job is triggered and exit with final result.)
WaitForResult=""
#Example WaitForResul="yes"

Просмотреть файл

@ -12,14 +12,14 @@
</test>
<test>
<TestName>VERIFY-HOSTNAME</TestName>
<testScript>BVT-VERIFY-HOSTNAME.py</testScript>
<PowershellScript>BVT-VERIFY-HOSTNAME.ps1</PowershellScript>
<files>.\Testscripts\Linux\nslookup.py,.\Testscripts\Linux\BVT-VERIFY-HOSTNAME.py,.\Testscripts\Linux\azuremodules.py</files>
<testScript>WALA-VERIFY-HOSTNAME.py</testScript>
<PowershellScript>WALA-VERIFY-HOSTNAME.ps1</PowershellScript>
<files>.\Testscripts\Linux\nslookup.py,.\Testscripts\Linux\WALA-VERIFY-HOSTNAME.py,.\Testscripts\Linux\azuremodules.py</files>
<setupType>SingleVM</setupType>
<Platform>Azure</Platform>
<Category>Smoke</Category>
<Area>default</Area>
<Tags>bvt</Tags>
<Tags>bvt,wala</Tags>
<TestID>Smoke_002</TestID>
</test>
<test>