Changed deprecated Hudson.getInstance() to Jenkins.getInstance().
Added more informative error message, if Jenkins instance is null. (Is there a work around?)