[JIRA] (JENKINS-61901) Cannot use property value from Folder properties in Jenkinsfile pipeline script

8 views
Skip to first unread message

smurugesh1686@gmail.com (JIRA)

unread,
Apr 14, 2020, 2:51:09 PM4/14/20
to jenkinsc...@googlegroups.com
Murugesh Subramaniam updated an issue
 
Jenkins / Bug JENKINS-61901
Cannot use property value from Folder properties in Jenkinsfile pipeline script
Change By: Murugesh Subramaniam
Summary: Cannot use property value from Folder properties in Jenkinfile Jenkinsfile pipeline script
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

smurugesh1686@gmail.com (JIRA)

unread,
Apr 14, 2020, 2:56:03 PM4/14/20
to jenkinsc...@googlegroups.com
Murugesh Subramaniam updated an issue
Steps to reproduce:

1. Create a multibranch pipeline inside a folder
2. Configure  Folder properties with Name: "testURL" Value"http://10.**.**.**:****"



In Jenkinsfile Script content:
{code:java}
def someArrayList = []

println someArrayList
withFolderProperties{ echo "URL STEP 1: ${env . name testURL}" }
{code}
This works with Sandbox disabled. When enabled, the The following exception is thrown:
{noformat}
ERROR No such field found : Build step failed with exception field java.lang.String mapiURL. Administrators can decide whether to approve or reject this signature.
[Pipeline] End of Pipeline
org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: No such field found: field java. util lang . ArrayList name String mapiURL
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.unclassifiedField(SandboxInterceptor.java:
397 425 )
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:
381 409 )
at org.kohsuke.groovy.sandbox.impl.Checker$
6 7 .call(Checker.java: 288 353 )
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:
292 357 )
at
org com . kohsuke cloudbees .groovy. cps. sandbox. SandboxInvoker.getProperty(SandboxInvoker.java:29)
at com.cloudbees.groovy.cps.
impl. Checker PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
at WorkflowScript.run(WorkflowScript:94)
at ___cps.transform___(Native Method)
at com.cloudbees.groovy.cps.impl.PropertyishBlock
$ checkedGetProperty ContinuationImpl . callStatic get ( PropertyishBlock.java:74)
at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.fixName(PropertyishBlock.java:66)
at sun.reflect.GeneratedMethodAccessor461.invoke(
Unknown Source)
at
org sun . codehaus reflect . DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.cloudbees.
groovy. runtime cps . callsite impl . CallSiteArray ContinuationPtr$ContinuationImpl . defaultCallStatic receive ( CallSiteArray ContinuationPtr .java: 56 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. callsite GroovyCategorySupport$ThreadCategoryInfo . AbstractCallSite.callStatic use ( AbstractCallSite GroovyCategorySupport .java: 194 129 )
at org.codehaus.groovy.runtime.
callsite GroovyCategorySupport . AbstractCallSite use(GroovyCategorySupport . callStatic java:268)
at com.cloudbees.groovy.cps.Continuable.run0
( AbstractCallSite Continuable .java: 230 163 )
at
Script1 org . run jenkinsci.plugins.workflow.cps.SandboxContinuable.access$101 ( Script1 SandboxContinuable . groovy java : 3 34 )
at org.jenkinsci.plugins.
workflow.cps.SandboxContinuable.lambda$run0$0(SandboxContinuable.java:59)
at org.jenkinsci.plugins.
scriptsecurity.sandbox.groovy.GroovySandbox. run runInSandbox (GroovySandbox.java: 141 237 )
at org.jenkinsci.plugins.
scriptsecurity workflow . sandbox cps . groovy SandboxContinuable . SecureGroovyScript run0(SandboxContinuable . evaluate java:58)
at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk
( SecureGroovyScript CpsThread .java: 333 174 )
at
hudson org . jenkinsci. plugins. groovy workflow . SystemGroovy cps . CpsThreadGroup. run( SystemGroovy CpsThreadGroup .java: 95 347 )
at
hudson org . jenkinsci. plugins. groovy workflow . SystemGroovy cps . perform CpsThreadGroup.access$200 ( SystemGroovy CpsThreadGroup .java: 59 93 )
at
org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:259)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:247)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at
hudson. tasks remoting . BuildStepMonitor SingleLaneExecutorService $1. perform run ( BuildStepMonitor SingleLaneExecutorService .java: 20 131 )
at
hudson jenkins . model util . AbstractBuild ContextResettingExecutorService $ AbstractBuildExecution 1 . perform run ( AbstractBuild ContextResettingExecutorService .java: 744 28 )
at
hudson jenkins . model security . Build ImpersonatingExecutorService $ BuildExecution 1 . build run ( Build ImpersonatingExecutorService .java: 206 59 )
Caused: java.util.concurrent.ExecutionException
at hudson org . model jenkinsci . Build plugins.workflow.cps.CpsBodyExecution.get(CpsBodyExecution.java:308)
at com.mig82.folders.step.FolderPropertiesStep
$ BuildExecution Execution . doRun run ( Build FolderPropertiesStep .java: 163 55 )
at
hudson com . model mig82 . AbstractBuild folders.step.FolderPropertiesStep $ AbstractBuildExecution Execution .run( AbstractBuild FolderPropertiesStep .java: 504 37 )
at
hudson org . model jenkinsci . Run plugins . execute workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call ( Run AbstractSynchronousNonBlockingStepExecution .java: 1724 47 )
at hudson.
model security . FreeStyleBuild ACL . impersonate(ACL.java:290)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.
run( FreeStyleBuild AbstractSynchronousNonBlockingStepExecution .java: 43 44 )
at
hudson java . model util . ResourceController concurrent . execute Executors$RunnableAdapter.call ( ResourceController Executors .java: 97 511 )
at
hudson java . model util . Executor concurrent . FutureTask. run( Executor FutureTask .java: 429 266 )
Build step 'Execute system Groovy script' marked build as failure 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
{noformat}
It looks like, outside the sandbox, groovy evaluates
{code:java}
someArrayList.name
{code}
to
{code:java}
someArrayList.collect { it.name }
{code}
but inside the sandbox, this doesn't happen.  

Feedback from Andrew:
{ quote}fwiw, it's [https://github.com/apache/groovy/blob/eedc6bfcd134749e7d76b05031dfbd914cec2d6e/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L7855] we need to somehow handle - we have to check the contents of the list to see if the objects in there can have that field accessed.
{quote}
The workaround currently is to change to using:
{
code:java}
someArrayList.collect { it.name }
{
code}
when using the sandbox.

smurugesh1686@gmail.com (JIRA)

unread,
Apr 14, 2020, 2:57:03 PM4/14/20
to jenkinsc...@googlegroups.com
Murugesh Subramaniam updated an issue
Steps to reproduce:

1. Create a multibranch pipeline inside a folder
2. Configure  Folder properties with Name: "testURL" Value"http://10.**.**.**:****"

In Jenkinsfile Script content:
{code:java}
withFolderProperties{ echo "URL STEP 1: ${env.testURL}" }
{code}

The following exception is thrown:
{noformat}
No such field found: field java.lang.String mapiURL testURL . Administrators can decide whether to approve or reject this signature.
[Pipeline] End of Pipeline
org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: No such field found: field java.lang.String
mapiURL tesURL
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.unclassifiedField(SandboxInterceptor.java:425)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:409)
at org.kohsuke.groovy.sandbox.impl.Checker$7.call(Checker.java:353)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:357)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:29)
at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)

at WorkflowScript.run(WorkflowScript:94)
at ___cps.transform___(Native Method)
at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.get(PropertyishBlock.java:74)

at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.fixName(PropertyishBlock.java:66)
at sun.reflect.GeneratedMethodAccessor461.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:129)
at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$101(SandboxContinuable.java:34)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.lambda$run0$0(SandboxContinuable.java:59)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:237)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:58)
at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:347)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:93)

at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:259)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:247)
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)
Caused: java.util.concurrent.ExecutionException
at org.jenkinsci.plugins.workflow.cps.CpsBodyExecution.get(CpsBodyExecution.java:308)
at com.mig82.folders.step.FolderPropertiesStep$Execution.run(FolderPropertiesStep.java:55)
at com.mig82.folders.step.FolderPropertiesStep$Execution.run(FolderPropertiesStep.java:37)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
at hudson.security.ACL.impersonate(ACL.java:290)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
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
{noformat}
It looks like, outside the sandbox, groovy evaluates
{code:java}
someArrayList.name
{code}
to
{code:java}
someArrayList.collect { it.name }
{code}
 

{code:java}
{code}
when using the sandbox.

smurugesh1686@gmail.com (JIRA)

unread,
Apr 14, 2020, 3:01:04 PM4/14/20
to jenkinsc...@googlegroups.com
Murugesh Subramaniam updated an issue
Steps to reproduce:

1. Create a multibranch pipeline inside a folder
2. Configure  Folder properties with Name: "testURL" & Value"http://10.**.**.**:****"


In Jenkinsfile Script content:
{code:java}
withFolderProperties{ echo "URL STEP 1: ${env.testURL}" }
{code}
The following exception is thrown:
{noformat}
No such field found: field java.lang.String testURL. Administrators can decide whether to approve or reject this signature.
[Pipeline] End of Pipeline
org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: No such field found: field java.lang.String tesURL
Reply all
Reply to author
Forward
0 new messages