How to identify exactly where exception occurred in Jenkins pipeline?

30 views
Skip to first unread message

Gajanan Mahajan

unread,
Jul 31, 2020, 12:54:57 AM7/31/20
to Jenkins Users
In Jenkins pipeline build, sometimes I've seen null pointer or other exceptions like -

    java.lang.NullPointerException: Cannot invoke method trim() on null object

Generally if we run Java program through IDE or command line, if an exception occurs we see at which line number the exception has occurred.

But with Jenkins build output console, it does not show the line number where the exception has occurred.

In this case, based on method name ie `trim()` from log, I check wherever `trim()` method is used. But as I've used it at multiple places in same method, it becomes difficult to identify exactly where error has occurred.

Another way is to add echo statements and re-run build and see where it gives this exception but this is time consuming.

Is there any better way/plugin using which I can identify at which line of pipeline code exception has occurred?

Ramanathan Muthaiah

unread,
Aug 2, 2020, 4:41:13 AM8/2/20
to Jenkins Users
But with Jenkins build output console, it does not show the line number where the exception has occurred.

In this case, based on method name ie `trim()` from log, I check wherever `trim()` method is used. But as I've used it at multiple places in same method, it becomes difficult to identify exactly where error has occurred.

Another way is to add echo statements and re-run build and see where it gives this exception but this is time consuming.

Is there any better way/plugin using which I can identify at which line of pipeline code exception has occurred?

You can try some of these methods:

i. In the humongous stack trace, search for workflow script with the line number, like, for example, 'workflow script: 70'.

Pls excuse for the shameful drum beating.



/Ram
Reply all
Reply to author
Forward
0 new messages