Issue
Pipeline load
directive throws IOException
instead of FileNotFoundException
if file not found when run in agent.
Environment
-
CloudBees CI (CloudBees Core) on modern cloud platforms - Managed controller
-
CloudBees CI (CloudBees Core) on traditional platforms - Client controller
-
CloudBees Jenkins Enterprise - Managed controller
Resolution
If using a try / catch block to determine the root cause of the exception, you need to unwrap the IOException
to uncover the root cause.
Example:
node { try { load 'filethatdoesnotexist.ext' } catch(FileNotFoundException e) { // do something } catch(IOException e) { if(e.getCause() instanceof FileNotFoundException) { // Inner exception is FileNotFoundException // do something } else { // do something else } } }
This article is part of our Knowledge Base and is provided for guidance-based purposes only. The solutions or workarounds described here are not officially supported by CloudBees and may not be applicable in all environments. Use at your own discretion, and test changes in a safe environment before applying them to production systems.