I have a pipeline script like this:
node('linux'){
stage('Setup'){
echo "Build Stage"
} stage('Build'){
echo "Build Stage"
} stage('Test'){
echo "Test Stage"
}
}
The Setup stage runs fine but an exception is thrown after that
java.lang.NullPointerException: Cannot invoke method stage() on null object
at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:91)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:48)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:35)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:157)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:159)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
at WorkflowScript.run(WorkflowScript:2)
at ___cps.transform___(Native Method)
at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57)
what could be wrong?
stage('Setup'){ echo "Build Stage" } stage('Build'){
stage is a method invocation which returns null. Your stage('Build'){ is attempting to be called on the null object which is why you get your NullPointerException.
Move your stage invocation to a new line or add a semicolon to separate the statements.
stage('Setup'){
echo "Build Stage"
}; stage('Build'){
stage('Setup'){
echo "Build Stage"
}
stage('Build'){
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With