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

Conversation

bishal-pdMSFT
Copy link
Contributor

Fixes #6466

Param ()

$agentVersion = Get-VstsTaskVariable -Name 'agent.version'
if (!$agentVersion -or (([version]'2.115.0').CompareTo([version]$agentVersion) -ge 1))
Copy link
Contributor

Choose a reason for hiding this comment

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

This check just make sure the agent version is greater than 2.115.0 and the variable Agent.TempDirectory is defined since then. However, don't we need to check if Agent.TempDirectory is shorter than env:Temp for real?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My assumption is that agent directory will mostly be smaller than temp directory. However, better to not make any assumption. Updated code.

{
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

@@ -204,4 +205,27 @@ function Merge-HashTables
}
$HashTableNew = $HashTableOld + $HashTableNew
return $HashTableNew
}

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


$agentVersion = Get-VstsTaskVariable -Name 'agent.version'
$envTemp = $env:Temp
if ($agentVersion -and (([version]'2.115.0').CompareTo([version]$agentVersion) -lt 1))
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 ifs can be combined using:
$envTemp = $env:TEMP
$agentTemp = $env:AGENT_TEMPDIRECTORY

if ($agentTemp -and $agentTemp.Length -lt $tmp.Length)
{
return $agentTemp
}
return $envTemp

If the agent doesn't support AGENT_TEMPDIRECTORY it will not be defined

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have removed check for agent version. Still using Get-VstsTaskVariable to get agent temp dir rather than depend on $env

Copy link
Member

@NCarlsonMSFT NCarlsonMSFT left a comment

Choose a reason for hiding this comment

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

Looks like the tests for Invoke-ActionWithRetries is now failing

@bishal-pdMSFT bishal-pdMSFT merged commit d7699c0 into master Mar 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants