-
Bug
-
Resolution: Unresolved
-
Major
-
Jenkins version- 2.263.4.2
Workflow CPS Plugin version- 2.87
When echo statement containing a string with a variable is executed from inside withCredentials block whose username and password are empty, then build is failing with below error:
java.lang.NullPointerException at org.jenkinsci.plugins.workflow.cps.DSL.lambda$logInterpolationWarnings$1(DSL.java:379) at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174) at java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1556) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566) at org.jenkinsci.plugins.workflow.cps.DSL.logInterpolationWarnings(DSL.java:380) at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:292) at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:193) at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122) at sun.reflect.GeneratedMethodAccessor2228.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42) 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:163) at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:157) at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:161) at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:165) at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:135) at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:135) at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
Below is the pipeline code executed which caused the above error:
node('random-node') { withCredentials([withCredentials([ usernamePassword(credentialsId: 'test-creds', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { // test-creds credential is created in Jenkins with empty values for username and password // Random string containing more than 1024 characters def str = "vipxxtdyaftkmhwktlfluinntglqgxhxbzmqrtdymiirdldqlqwkbwogghipikynerlnbzvikbstrbltvzbrwhgexagknwjrbslhtyrdrjawximhudnfpevdnfnypslcbdoahbwoymvstadapkvatuawfcuhssuejpuzkgvzqguxzcpxztpuxexvpecistficnlnxmngsfwadwiiwqsjsoirtzzuupuxtxadkcmhoewdytsddmpkvbwufqhzimawrqywiswlblsvioigswyfewctzabmppnzxwlmheleqkdgkreuraofcwgfctraahumshkwrjxljcgpyihpgapewkhzbwmnslmbgpnntxgnwtcjcpytgypsihcxntaufamhhrjtbdclyhojkxamglhbixcmknrlghpfyqmglhxzeqfixeihmkgeroyjctblvwnjefnhieainpaijplqzgfhtifvcfzfmgbocmkhheqpusznlkgbxtkmvwcnxywzhdugmdhlqjpuwhmmaadfpfgqtxvujewxejyuthzgxbfshzgokinkrrkzqiuogdafsajslofavaxxgpxouiqwmpkjetmeqhvjagmufwopanpwtoigfmvvriqcjqywviqirfdhxkxyijvvkjujzsndlctbuzwapkppkmgdveodmskxtzsbizeizyblusifyzamhxemdsodvjpvurmjfmsvajvnpwwvhrdnfmvmicjdjtiawqquhyxaugtgsojmkzjlbanvceapbmmzunhbaoucukvplwrrdyvhasovtjnuhzanvxfycwkeymweinubqezuuqcqgqoaynwrkuohfwmjfvzlklumeawmkcqardbuhwpowsrjbevmaioojsvcdlieyqtdzwfoavtqgygltuayrfnkbuvecyatpvydctavglzdexlywqwqahnlidvdnrlvkmexlvtvmmfqzjpdzhaauraqszxsyhflnnwruswgrqulnewshsledbwotfwjgdozmzuwa" echo "${str}" } }
This error seem to be observed only when:
- username and password are empty in the credential
- echo step prints a variable
- no. of characters set in the value of the variable is more than 1024 characters