FileNotFoundException when using comment file path
See original GitHub issueI’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:
- Created 7 years ago
- Comments:8 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
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.