cmdenvironment-variablesazure-pipelinesrscriptazure-devops-self-hosted-agent

Unable to save output from Rscripts in system directory using Devops Pipeline


I am running Rscripts on a self hosted Devops agent. My Windows agent is able to access the system's directory where its hosted. Below is the directory structure for my code

Cloud Agent : D:/folder

Source Code : D:/folder/project

Data _dump : D:/folder/dump/

Output : D:/folder/project/output_data/

The agent is using CMD in the devops pipeline to trigger R from the system and use the libraries from the system directory.

Problem statement: I am unable to save the output from my Rscript in to the Output Loca. directory. It give an error as Probable reason: permission denied error by pointing to that directory.

Output File Format: file_name.rds but same issue happens even for a csv file.

Command leading to failure: saverds(paste0(Output loca.,"/",file_name.rds))

Workaround : However I found a workaround, tried to save the scripts at the Source Code directory and then save the same files at the Output Loca. directory. This works perfectly fine but costs me 2 extra hours of run time because I have to save all intermediatory files and delete them in the end. Keeping the intermediatory files in memory eats up my RAM.

I have not opened that directory anywhere in the machine. Only open application in my explorer is my browser where the pipeline is running. I spent hours to figure out the reason but no success. Even I checked the system Path to see whether I have mentioned that directory over there and its not present.

When I run the same script directly, on the machine using Rstudio, I do not have any issues with saving the file at any directory.

Spent 2 full days already. Any pointers to figure out the root cause can save me few hours of runtime.


Solution

  • Solution was to set the Azure Pipeline Agent services in Windows to run with Admin Credentials. The agent was not configured as an admin during creation and so after enabling it with my userid which has admin access on the VM, the pipelines were able to save files without any troubles.

    Feels great, saved few hours of run time!

    I was able to achieve this by following this post.