How to identify exactly where exception occurred in Jenkins pipeline?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to identify exactly where exception occurred in Jenkins pipeline?

Gajanan Mahajan
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?

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/de0645e5-6edb-4d52-ae0d-03c2667fb3b6o%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: How to identify exactly where exception occurred in Jenkins pipeline?

Ramanathan Muthaiah
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.

ii. https://dzone.com/articles/10-tips-to-debug-jenkins-pipelines

iii. https://dzone.com/articles/tips-to-debug-jenkins-v2x-pipeline-scripts-part-2

/Ram

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/48ba7f7f-313e-475b-8f41-9daf67888e12o%40googlegroups.com.