Sunday, September 8, 2019

Resolving Windows Machine File Copy Task Failed With Access Denied Issue

Windows machine file copy task in Azure DevOps pipeline is used to copy files to remote windows machines. In this blog we are going to discuss the access denied issue which might occur in this task. When we use this task in the deployment pipeline to copy automation scripts to test client machine, suddenly, deployment pipeline started failing with an access denied issue as stated below. Let’s look at how it was resolved to which might help you as well if you run into the same problem.
 ROBOCOPY     ::     Robust File Copy for Windows                            
Access is denied.
ERROR 5 (0x00000005) Creating Destination Directory \\do-tf-tc02\C$\dotest\
Access is denied.
##[error]System.Management.Automation.RuntimeException: Copying failed for resource : do-tf-tc02
[debug]Processed: ##vso[task.logissue type=error;]System.Management.Automation.RuntimeException: Copying failed for resource : do-tf-tc02
Copying failed. Consult the robocopy logs for more details. ---> System.Management.Automation.RuntimeException: Copying failed for resource : do-tf-tc02
Copying failed. Consult the robocopy logs for more details.
System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
Microsoft.TeamFoundation.DistributedTask.Handlers.LegacyVSTSPowerShellHost.VSTSPowerShellHost.Main(String[] args)
##[error]LegacyVSTSPowerShellHost.exe completed with return code: -1.


Following is the debug log file of the failed Windows machine copy task.


While looking for a solution, as the first step, we checked the current access permission of the folder location where files going to be copied. We have observed the current user has all the required permission to access the file location. So, it doesn't require to do any changes to current user access permission to the folder location of the test client machine.


So, we assume there are no issues in test client machine or the user permissions. Next thing we can check is the deployment pipeline task. This failure might occur due to the issue in the release pipeline. So, we checked the Windows machine copy task. It has two versions as version 1 and 2. We upgrade the task version from 1 to 2.


It solves the issue. Files are copied successfully after upgrade the task version.




This post would be helpful to you if you encounter the same problem in the Windows machine copy task in the Azure DevOps pipeline.

No comments:

Post a Comment