Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics

Dashboard
Notifications
Mark all as read
Q&A

Jenkins failed to delete a file - why? How to prevent?

+2
−0

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:

20:29:53 P4 Task: failed: java.io.IOException: Unable to delete file: c:\Jenkins\blahblah...

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 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?

Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

3 comments

I think in order to fully understand you should provide more details. Is this task a custom task? (e.g. removes an existing file and downloads a newer version). The error might also appear when the file to delete is not found. Since this is not always happening, I suspect it is not related to Jenkins user lacking the right to delete that file. Alexei‭ about 2 months ago

It's not a custom task; I updated my post to include more details. anatolyg‭ about 2 months ago

Is the failure happening at the P4 checkout time, or in a cleanup phase at the end? And do you rerun the job in the same directory each time, or do you use a new scratch directory each time? Monica Cellio‭ about 2 months ago

1 answer

+2
−0

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:

Jenkins Task Console Output Menu Link

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:

Jenkins Job Task IDs

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.

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comments

Sign up to answer this question »