Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
amit-avit committed Mar 18, 2021
1 parent eef39f9 commit faec168
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 60 deletions.
4 changes: 0 additions & 4 deletions Tasks/AzurePowerShellV2/AzurePowerShell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,4 @@ finally {

Import-Module $PSScriptRoot\ps_modules\VstsAzureHelpers_
Disconnect-AzureAndClearContext -authScheme $authScheme -ErrorAction SilentlyContinue

# Telemetry
$telemetryJsonContent = @{ targetAzurePs = $targetAzurePs } | ConvertTo-Json -Compress
Write-Host "##vso[telemetry.publish area=TaskHub;feature=AzurePowerShellV2]$telemetryJsonContent"
}
84 changes: 58 additions & 26 deletions Tasks/AzurePowerShellV2/TryMakingModuleAvailable.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,68 @@ param (
$targetVersion
)

. "$PSScriptRoot\Utility.ps1"
$moduleContainerPath = Get-SavedModuleContainerPath
try {
. "$PSScriptRoot\Utility.ps1"
$moduleContainerPath = Get-SavedModuleContainerPath

if (-not(Test-Path -Path $moduleContainerPath)) {
Write-Verbose "Folder layout not as per hosted agent, considering self hosted agent skipping module unzip logic."
return;
}

if (!$targetVersion) {
Write-Verbose "Latest module selected which will be available as folder."
return;
}

# value for classic
@($false, $true).ForEach({
$modulePath = Get-SavedModulePath -azurePowerShellVersion $targetVersion -Classic:$_;
if (Test-Path -Path $modulePath) {
Write-Verbose "Module available as folder at $modulePath"
if (-not(Test-Path -Path $moduleContainerPath)) {
$classicModuleSource = "privateAgent"
$nonClassicModuleSource = "privateAgent"
Write-Verbose "Folder layout not as per hosted agent, considering self hosted agent skipping module unzip logic."
return;
}

$moduleZipPath = $modulePath + ".zip";
if (-not(Test-Path -Path $moduleZipPath)) {
Write-Verbose "Module zip not available to unzip at $moduleZipPath"
if (!$targetVersion) {
$classicModuleSource = "hostedAgentFolder"
$nonClassicModuleSource = "hostedAgentFolder"
Write-Verbose "Latest module selected which will be available as folder."
return;
}

Write-Verbose "Extracting zip $moduleZipPath"
$parameter = @("x", "-o$moduleContainerPath", "$moduleZipPath")
$command = "$PSScriptRoot\7zip\7z.exe"
&$command @parameter
Write-Verbose "Extraction complete"
})
# value for classic
@($false, $true).ForEach({
$modulePath = Get-SavedModulePath -azurePowerShellVersion $targetVersion -Classic:$_;
if (Test-Path -Path $modulePath) {
if ($_) {
$classicModuleSource = "hostedAgentFolder"
} else {
$nonClassicModuleSource = "hostedAgentFolder"
}

Write-Verbose "Module available as folder at $modulePath"
return;
}

$moduleZipPath = $modulePath + ".zip";
if (-not(Test-Path -Path $moduleZipPath)) {
if ($_) {
$classicModuleSource = "hostedAgentOthers"
} else {
$nonClassicModuleSource = "hostedAgentOthers"
}

Write-Verbose "Module zip not available to unzip at $moduleZipPath"
return;
}

if ($_) {
$classicModuleSource = "hostedAgentZip"
} else {
$nonClassicModuleSource = "hostedAgentZip"
}

Write-Verbose "Extracting zip $moduleZipPath"
$parameter = @("x", "-o$moduleContainerPath", "$moduleZipPath")
$command = "$PSScriptRoot\7zip\7z.exe"
&$command @parameter
Write-Verbose "Extraction complete"
})
} finally {
# Telemetry
$telemetryJsonContent = @{
targetAzurePs = $targetVersion;
classicModuleSource = $classicModuleSource;
nonClassicModuleSource = $nonClassicModuleSource
} | ConvertTo-Json -Compress
Write-Host "##vso[telemetry.publish area=TaskHub;feature=AzurePowerShellV2]$telemetryJsonContent"
}
4 changes: 0 additions & 4 deletions Tasks/AzurePowerShellV3/AzurePowerShell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,3 @@ finally {
}
Write-Host "## Script Execution Complete"
Disconnect-AzureAndClearContext -authScheme $authScheme -ErrorAction SilentlyContinue

# Telemetry
$telemetryJsonContent = @{ targetAzurePs = $targetAzurePs } | ConvertTo-Json -Compress
Write-Host "##vso[telemetry.publish area=TaskHub;feature=AzurePowerShellV3]$telemetryJsonContent"
84 changes: 58 additions & 26 deletions Tasks/AzurePowerShellV3/TryMakingModuleAvailable.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,68 @@ param (
$targetVersion
)

. "$PSScriptRoot\Utility.ps1"
$moduleContainerPath = Get-SavedModuleContainerPath
try {
. "$PSScriptRoot\Utility.ps1"
$moduleContainerPath = Get-SavedModuleContainerPath

if (-not(Test-Path -Path $moduleContainerPath)) {
Write-Verbose "Folder layout not as per hosted agent, considering self hosted agent skipping module unzip logic."
return;
}

if (!$targetVersion) {
Write-Verbose "Latest module selected which will be available as folder."
return;
}

# value for classic
@($false, $true).ForEach({
$modulePath = Get-SavedModulePath -azurePowerShellVersion $targetVersion -Classic:$_;
if (Test-Path -Path $modulePath) {
Write-Verbose "Module available as folder at $modulePath"
if (-not(Test-Path -Path $moduleContainerPath)) {
$classicModuleSource = "privateAgent"
$nonClassicModuleSource = "privateAgent"
Write-Verbose "Folder layout not as per hosted agent, considering self hosted agent skipping module unzip logic."
return;
}

$moduleZipPath = $modulePath + ".zip";
if (-not(Test-Path -Path $moduleZipPath)) {
Write-Verbose "Module zip not available to unzip at $moduleZipPath"
if (!$targetVersion) {
$classicModuleSource = "hostedAgentFolder"
$nonClassicModuleSource = "hostedAgentFolder"
Write-Verbose "Latest module selected which will be available as folder."
return;
}

Write-Verbose "Extracting zip $moduleZipPath"
$parameter = @("x", "-o$moduleContainerPath", "$moduleZipPath")
$command = "$PSScriptRoot\7zip\7z.exe"
&$command @parameter
Write-Verbose "Extraction complete"
})
# value for classic
@($false, $true).ForEach({
$modulePath = Get-SavedModulePath -azurePowerShellVersion $targetVersion -Classic:$_;
if (Test-Path -Path $modulePath) {
if ($_) {
$classicModuleSource = "hostedAgentFolder"
} else {
$nonClassicModuleSource = "hostedAgentFolder"
}

Write-Verbose "Module available as folder at $modulePath"
return;
}

$moduleZipPath = $modulePath + ".zip";
if (-not(Test-Path -Path $moduleZipPath)) {
if ($_) {
$classicModuleSource = "hostedAgentOthers"
} else {
$nonClassicModuleSource = "hostedAgentOthers"
}

Write-Verbose "Module zip not available to unzip at $moduleZipPath"
return;
}

if ($_) {
$classicModuleSource = "hostedAgentZip"
} else {
$nonClassicModuleSource = "hostedAgentZip"
}

Write-Verbose "Extracting zip $moduleZipPath"
$parameter = @("x", "-o$moduleContainerPath", "$moduleZipPath")
$command = "$PSScriptRoot\7zip\7z.exe"
&$command @parameter
Write-Verbose "Extraction complete"
})
} finally {
# Telemetry
$telemetryJsonContent = @{
targetAzurePs = $targetVersion;
classicModuleSource = $classicModuleSource;
nonClassicModuleSource = $nonClassicModuleSource
} | ConvertTo-Json -Compress
Write-Host "##vso[telemetry.publish area=TaskHub;feature=AzurePowerShellV3]$telemetryJsonContent"
}

0 comments on commit faec168

Please sign in to comment.