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
In case anyone is curious, I identified two sources of this issue.
1) JGit is throwing exceptions because nanosecond resolution is set to
UNDEFINED and any time you do math (add a value) with that value in Java
long, you get an Arithmetic Overflow. This seems to have left some threads
in an
Try nesting that in a script block
pipeline {
agent any
stages {
stage('example') {
steps {
* script {*
def causes = currentBuild.getBuildCauses()
echo "Causes are ${causes}"
* }*
}
}
}
}
Hi,
that is a confusing error in my point of view that you will learn to
interpret :-)
The pipeline you wrote is a declarative one and the usage of "def ... " is
something you can do only in scripted pipelines ... hence, what the error
really means is: "You forgot to open a script block".