question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FileNotFoundException when using comment file path

See original GitHub issue

I’m trying to use comment file path to add comment to PRs with some analysis results read from a text file that has previously been created during build phase. According to build log, reading comment file seems to be the last build step that was executed, which means the file should already exist at that point, but I still get FileNotFoundException. The path I use is ${WORKSPACE}/path/to/comment/file and I double check to make sure it exists.

The job was executed on a remote slave machine, which is connected by Jenkins master via SSH. I suspect the plugin was trying to read a file on Jenkins master and thus couldn’t find the file, whose path is meant for the slave machine, but I could be wrong.

Some context:

  • Jenkins version: 1.651.1
  • Gihub plugin version: 1.18.1
  • Github API plugin version: 1.72.1
  • Github authentication plugin version: 0.22.3
  • GHPRB plugin version: 1.31.2

Full stack trace:

Couldn't read comment file
java.io.FileNotFoundException: File '/var/slave/workspace/job/lint-results.txt' does not exist
    at org.apache.commons.io.FileUtils.openInputStream(FileUtils.java:299)
    at org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:1711)
    at org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:1748)
    at org.jenkinsci.plugins.ghprb.extensions.comments.GhprbCommentFile.postBuildComment(GhprbCommentFile.java:45)
    at org.jenkinsci.plugins.ghprb.GhprbBuilds.commentOnBuildResult(GhprbBuilds.java:227)
    at org.jenkinsci.plugins.ghprb.GhprbBuilds.onCompleted(GhprbBuilds.java:202)
    at org.jenkinsci.plugins.ghprb.GhprbBuildListener.onCompleted(GhprbBuildListener.java:32)
    at org.jenkinsci.plugins.ghprb.GhprbBuildListener.onCompleted(GhprbBuildListener.java:17)
    at hudson.model.listeners.RunListener.fireCompleted(RunListener.java:201)
    at hudson.model.Run.execute(Run.java:1783)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:410)

!!! Couldn't read commit file !!!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
SVilgelmcommented, Aug 9, 2016

Ok. I investigated a little bit into this problem. It happens if the build starts on a slave, on a master node everything works fine.

0reactions
ghostcommented, Jul 27, 2018

If the Jenkinsfile is in subdirectory, specify the sub directory (ex: test/Portal/Jenkinsfile) path till the Jenkinsfile and then uncheck the Lightweight checkout.

Now build the project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Valid file path throws java.io.FileNotFoundException
It turns out the issue was with trailing newlines.
Read more >
FileNotFoundException in Java - Baeldung
A file with the specified pathname does exist but is inaccessible for some reason (requested writing for a read-only file, or permissions don't ......
Read more >
[Solved] java.io.FileNotFoundException in Java with Examples
This exception mainly occurs for the below reasons: 1. If the application tries to open a file, but the file is not present...
Read more >
java.io.FileNotFoundException in Java - GeeksforGeeks
FileNotFoundException which is a common exception which occurs while we try to access a file. FileNotFoundExcetion is thrown by constructors ...
Read more >
java.io.FileNotFoundException – How to solve File Not Found ...
FileNotFoundException, through detailed ex. ... a file that a program tries to access does not exist or the file path is actually a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found