Why does somestring.digest('SHA-1') fail in pipeline

30 views
Skip to first unread message

ZillaYT

unread,
Apr 30, 2019, 5:41:40 PM4/30/19
to Jenkins Users
I have this simple code and it works on my Macs groovy

String sigStr = 'iurpeirupru04790734'
sigStr
= sigStr.digest('SHA-1')
println sigStr

But I get this error when I run it in a Jenkins pipeline. Why? Thanks!

hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: java.lang.String.digest() is applicable for argument types: (java.lang.String) values: [SHA-1] Possible solutions: getAt(java.lang.String), size(), toSet(), size(), next(), toList()
 at org
.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58)
 at org
.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:49)
 at org
.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
 at org
.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
 at com
.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
 at
WorkflowScript.run(WorkflowScript:6)
 at ___cps
.transform___(Native Method)
 at com
.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57)
 at com
.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
 at com
.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
 at sun
.reflect.GeneratedMethodAccessor372.invoke(Unknown Source)
 at sun
.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java
.lang.reflect.Method.invoke(Method.java:498)
 at com
.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
 at com
.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
 at com
.cloudbees.groovy.cps.Next.step(Next.java:83)
 at com
.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
 at com
.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
 at org
.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:122)
 at org
.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:261)
 at com
.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
 at org
.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174)
 at org
.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:332)
 at org
.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:83)
 at org
.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:244)
 at org
.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:232)
 at org
.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
 at java
.util.concurrent.FutureTask.run(FutureTask.java:266)
 at hudson
.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
 at jenkins
.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
 at jenkins
.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
 at java
.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
 at java
.util.concurrent.FutureTask.run(FutureTask.java:266)
 at java
.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
 at java
.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
 at java
.lang.Thread.run(Thread.java:748)
Finished: FAILURE


Slide

unread,
Apr 30, 2019, 8:11:36 PM4/30/19
to Jenkins User Mailing List
Pipeline is a subset of groovy, so something may not work in pipeline that work in groovy standalone. It also may depend on what version of groovy pipeline is using as the digest method was added in groovy 2.5.0 I believe. I don't know what version pipeline is using right now.

--
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 jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/86563179-18e2-4dd7-afeb-5859e1ecb7da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mykola Nikishov

unread,
May 1, 2019, 6:15:16 AM5/1/19
to jenkins...@googlegroups.com
ZillaYT <zil...@gmail.com> writes:

> I have this simple code and it works on my Macs groovy
>
> String sigStr = 'iurpeirupru04790734'
> sigStr = sigStr.digest('SHA-1')
> println sigStr

Try

sigStr = sigStr.decodeBase64()

which is available since Groovy 1.0 [1]

digest() is available since 2.5.0 [2].

[1] http://docs.groovy-lang.org/2.4.0/html/api/org/codehaus/groovy/runtime/EncodingGroovyMethods.html
[2] http://docs.groovy-lang.org/latest/html/api/org/codehaus/groovy/runtime/EncodingGroovyMethods.html

> But I get this error when I run it in a Jenkins pipeline. Why? Thanks!

Different Groovy version?

> hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No
> signature of method: java.lang.String.digest() is applicable for argument
> types: (java.lang.String) values: [SHA-1] Possible solutions: getAt(java.
> lang.String), size(), toSet(), size(), next(), toList()

--
Mykola

Libre/Free Java Software Developer
https://manandbytes.gitlab.io/

Daniel Beck

unread,
May 1, 2019, 1:55:16 PM5/1/19
to jenkins...@googlegroups.com


> On 1. May 2019, at 02:11, Slide <slide...@gmail.com> wrote:
>
> I don't know what version pipeline is using right now.

We're on 2.4.x.

And as usual, don't (ab)use pipeline as a general purpose programming environment. It's not intended to be, never was.

ZillaYT

unread,
May 1, 2019, 4:08:58 PM5/1/19
to Jenkins Users
Jenkins pipeline has been working for us so far, except for these little gotchas.

Thanks!

On Wednesday, May 1, 2019 at 1:55:16 PM UTC-4, Daniel Beck wrote:
Reply all
Reply to author
Forward
0 new messages