Running a C# script gives different results when in cmd vs Jenkins pipeline.
I’m running a Jenkins pipeline and in the post step I want to get the pipeline log from the server, split it into different files (one per stage) and upload it to some shared drive. This is all done via a C# script, here is the snippet of code that gives me the error:
if (File.Exists(logPath))
{
// copies the log file to current directory to avoid "file in use" error
string destPath = Directory.GetCurrentDirectory() + "/log.txt";
File.Copy(logPath, destPath, true);
m_priv_logPath = destPath;
}
else
{
throw new Exception("File "" + logPath + "" does not exist");
}
Running the same script with the exact same parameters from command line runs normally, but in Jenkins it goes in the else block, because File.Exists returns a false.
The log path is always a network path, so something like \<machine-name><job-name>jobsbuilds<build-number>log
I’m not sure how I can debug this or what could be causing it. Any ideas?