Suppose the Java plugin I'm writing is producing a report file. Within its node (slave) I will use filePath.child(fileOnDiskPath) to persist that report into that node workspace.
What happened now when I want to reference that report once the build is over?
From where do you want to access the file? UI, file system, web service?
How do I gain access to that node's location now that the job is over?
This is not possible, the node may be already destroyed or cleaned.
If I do run.getExecutor().getCurrentWorkspace() for getting the FilePath, I'm getting NullPointerException Obviously as nothing is running.
Is something wrong in this methodology?
Yes, your planned approach will never work. You need to register a new https://javadoc.jenkins-ci.org/hudson/model/Action.html that will be attached to the build. This action can serialize all information you need for retrieval and is visible in the UI. Or simply copy the file to the master build folder.