Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Jenkins failed to delete a file - why? How to prevent?
We are using Jenkins to run our system tests on a regular schedule. The Jenkins job downloads some python scripts from Perforce, runs them and compares the outputs with known-good results.
The problem is, sometimes downloading from Perforce fails:
12:46:19 operating system will not allow deletion of file c:\Jenkins\...(redacted)...\p4j5949332513673726584.tmp on client.
In the error message, P4 is a common abbreviation for Perforce. We have a Jenkins plugin called P4 which downloads files from Perforce; I guess it's this plugin that writes this error message. I think something is holding the temporary file open, that's why it couldn't be deleted.
What can I do to prevent this? I imagine that it can be caused by an antivirus, some person quietly browsing in the Jenkins's file system, a random cosmic ray, etc. How can I even start investigating this?
Did we do something fundamentally wrong in configuring our Jenkins job this way? Something which would completely prevent this issue from happening?
2 answers
I think you have the answer to your question within your own question, but let me make it a bit more explicit. You said:
The problem is, sometimes downloading from Perforce fails
If P4 fails to download the file, then it follows that the task will fail to delete the (non-existent) file(s).
What you need to check is why P4 is failing to download the file(s). You'll need to check the tasks logs.
How can I even start investigating this?
You should start with the Console Output menu link within the task itself, shown below:
You should be able to find out more, depending on how you've configured your jobs, plugins, and/or scripts being used by them. Regarding scripts, printing to STDOUT will make those messages show up in the Jenkins job logs.
To find the log for a particular job, you have to go into the job. You'll see a list of tasks that have already run, or are currently running, enumerated by job IDs as shown below:
Click on the relevant one task record, and find the console output link shown earlier.
Unfortunately, the next steps in your investigation will depend on what you find there, if anything. If you don't find anything, start looking at plugin/task configuration options and tweak them to see how you can get more info.
There's really not much more that I can say here, given your description.
0 comment threads
I don't know how to prove or discover this, but anyway.
This error happens when Jenkins job is interrupted while the P4 plugin is doing what it calls "reconcile". A "reconcile" is a special form of downloading, which is supposed to do it faster and/or more cleanly.
P4 plugin has several bugs related to "reconcile": 1, 2. They are probably not going to be fixed. A workaround is to never do "reconcile" but to delete all files and download them by force. The job settings-page calls this "Force Clean and Sync … (Inefficient and NOT RECOMENDED)".
Either that or "never stop any running job" as a policy. The latter is unintuitive and hard to enforce; in our case, some compound jobs are configured to stop all sub-jobs if one of them fails.
1 comment thread