I'm refactoring a packer template that has been used to build Windows images for Azure AVD using PackerTool
by riezebosch. The functioning template maps an Azure Files share that contains various files and scripts used during the build. I'd like to eliminate that and instead use the files and scripts from the repo. I know it gets cloned to the agent because one of the steps in the pipeline explicitly does so.
I've been struggling to figure out where these are located on the agent. I've checked $System.DefaultWorkingDirectory
which is C:\agent#\_work\#\s
. But, when I look for the files there, they aren't found. I've tried both with and without the repo name in the path
"$System.DefaultWorkingDirectory\\REPO\\Files"
and without
"System.DefaultWorkingDirectory\\Files"
Neither are correct.
In the template, if I run Get-Location
and assign it to a variable, then run ls
on the variable, it tells me I'm in C:\Users\packer
and that it contains the usual folders such as Desktop
, Downloads
, etc., but not the repo.
Running ls
on System.DefaultWorkingDirectory
throws an error:
==> azure-arm.npe-avd-image: ls : Cannot find path 'C:\agent2\_work\1\s' because it does not exist.
==> azure-arm.npe-avd-image: At C:\Windows\Temp\script-68017098-4026-8673-473e-9acb3278a9d2.ps1:1 char:1
==> azure-arm.npe-avd-image: + ls C:\agent2\_work\1\s
==> azure-arm.npe-avd-image: + ~~~~~~~~~~~~~~~~~~~~~~
==> azure-arm.npe-avd-image: + CategoryInfo : ObjectNotFound: (C:\agent2\_work\1\s:String) [Get-ChildItem], ItemNotFoundException
==> azure-arm.npe-avd-image: + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
I'm at a loss. I've looked around online but haven't been able to find anything that correctly tells me where the repo is cloned to.
After more closely scrutinizing the output from PackerTool, it appears the repo is being cloned to C:\agent#\_work\#\s
. I'll look in s
for the files. If I still don't find them, I'm testing cloning the repo to another, explicit location.