Getting semi-sporadic Access Denied using mapped network share over ssh managed jenkins agent

38 Views Asked by At

I have a Jenkins instance using the EC2 plugin to create Windows agents. I am using it slightly unconventionally in that I am claiming it is a Linux machine to use SSH management instead of WinRM management (WinRM is SUPER slow in my use case). From my googling, this is a semi-standard workaround.

In my Jenkins job, I am mapping a network share (samba share hosted on a Linux server, connected with user/pass) to a drive letter. I do this in the job otherwise the ssh session doesn't see the drive mapped in an actual user session.

I am then using Perforce via PowerShell to sync a workspace on that mapped drive.

The Jenkins job is executing this perforce sync as follows:

powershell "p4.exe ${p4GOpts} sync ${env.STREAM_DEPOT_PATH}/...@${P4_CHANGELIST}"

I unfortunately cannot use the p4 plugin because the p4sync pipeline step won't let me use a static workspace, it insists on making one which doesn't cooperate here. And using the p4groovy.run command is run blocking on the main thread which has a 5-minute wait timeout in Jenkins.

When I do this perforce proceeds to download and create a bunch of files, but then stops on semi-random files/folders with an "Access Denied"

//[Depot]/[Redacted].uasset#4 - deleted as J:\SharedBuildDepot\Test\[Redacted].uasset
powershell.exe : unlink: J:\SharedBuildDepot\Test\[Redacted].uasset: Access is denied. 
At C:\jenkins\workspace\[Redacted]\Dev@tmp\durable-b3b2e91f\powershellWrapper.ps1:3 char:1
+ & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Comm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (unlink: J:\Shar...ess is denied. :String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
Fatal client error; disconnecting!

As for "semi-random" it can end up syncing 200 files, then catch on a file. If I try and re-run the job it runs into the issue on the same file.

I have tried looking at file and folder permissions but everything looks ok. The Access Denied has occurred on pretty much every file op. Modifying an existing file, adding a new file, making a new directory, or deleting a file. This drive was empty before I started using it for this, there is only one user/pass that can create files on it and no other machines have used it. There doesn't seem to be any conflicting permissions.

Using the p4sync pipeline step works fine, but I haven't been able to configure it to point to the network share so I am not sure that is directly comparable.

If I RDP into the machine, map the drive using the same credentials, and sync the perforce workspace myself everything works fine, all files are synced successfully on the network drive which is what I expect to happen.

0

There are 0 best solutions below