Skip to content
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

Use agent's temp dir if available #6673

Merged
merged 7 commits into from
Mar 15, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions Tasks/ServiceFabricDeploy/ServiceFabricSDK/Utilities.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ function Get-NamesFromApplicationManifest
$appTypeSuffix = 'Type'

$h = @{
FabricNamespace = $FabricNamespace;
ApplicationTypeName = $appMan.ApplicationTypeName;
FabricNamespace = $FabricNamespace;
ApplicationTypeName = $appMan.ApplicationTypeName;
ApplicationTypeVersion = $appMan.ApplicationTypeVersion;
}

Expand Down Expand Up @@ -163,9 +163,10 @@ function Get-ApplicationParametersFromApplicationParameterFile

$hash = @{}
$ParametersXml.ChildNodes | foreach {
if ($_.LocalName -eq 'Parameter') {
$hash[$_.Name] = $_.Value
}
if ($_.LocalName -eq 'Parameter')
{
$hash[$_.Name] = $_.Value
}
}

return $hash
Expand Down Expand Up @@ -206,21 +207,25 @@ function Merge-HashTables
return $HashTableNew
}

function Get-TempDirectoryPath {
function Get-TempDirectoryPath
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider:
The Service Fabric Update Manifests task also uses a temp directory (although it uses $ENV:AGENT_TEMPDIRECTORY) Probably would be prudent to put this in the Service Fabric common scripts and use it in both places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#fixed

{
<#
.SYNOPSIS
Returns a temp directory path. Uses Agent.TempDirectory if available
Returns a temp directory path. Uses Agent.TempDirectory if available if shorter than env temp
#>

Param ()

$agentVersion = Get-VstsTaskVariable -Name 'agent.version'
if (!$agentVersion -or (([version]'2.115.0').CompareTo([version]$agentVersion) -ge 1))
{
return $env:Temp
}
else
$envTemp = $env:Temp
if ($agentVersion -and (([version]'2.115.0').CompareTo([version]$agentVersion) -lt 1))
{
return Get-VstsTaskVariable -Name 'Agent.TempDirectory'
$agentTemp = Get-VstsTaskVariable -Name 'Agent.TempDirectory'
if ($agentTemp.Length -le $envTemp)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$envTemp.Length?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed and added L0 tests as well

{
return $agentTemp
}
}

return $envTemp
}