[JIRA] (JENKINS-37817) Pipeline should be able to use hudson.plugins.git.GitSCM getBranches

241 views
Skip to first unread message

docwhat@gerf.org (JIRA)

unread,
Aug 30, 2016, 12:41:03 PM8/30/16
to jenkinsc...@googlegroups.com
Christian Höltje created an issue
 
Jenkins / Bug JENKINS-37817
Pipeline should be able to use hudson.plugins.git.GitSCM getBranches
Issue Type: Bug Bug
Assignee: Mark Waite
Components: git-plugin
Created: 2016/Aug/30 4:40 PM
Environment: Jenkins 2.7.2
Git-Plugin: 2.5.3
Priority: Minor Minor
Reporter: Christian Höltje

When trying to use scm.branches in a Jenkinsfile to perform a shallow clone:

checkout([
        $class: 'GitSCM',
        branches: scm.branches,
        doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
        extensions: scm.extensions + [[$class: 'CloneOption', noTags: false, reference: '', shallow: true]],
        submoduleCfg: [],
        userRemoteConfigs: scm.userRemoteConfigs
      ])

I get this error:

org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use method hudson.plugins.git.GitSCM getBranches
	at org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.StaticWhitelist.rejectMethod(StaticWhitelist.java:176)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor$6.reject(SandboxInterceptor.java:243)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:363)
	at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:241)
	at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:238)
	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:24)
	at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
	at WorkflowScript.run(WorkflowScript:12)
	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.GeneratedMethodAccessor751.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:58)
	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:33)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:30)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:30)
	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:164)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:361)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:80)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:236)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:226)
	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:47)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
	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:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

I would expect that I should be able to access scm.branches though I would prefer an easier way to just modify or copy-and-change the scm object.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

docwhat@gerf.org (JIRA)

unread,
Aug 30, 2016, 12:42:01 PM8/30/16
to jenkinsc...@googlegroups.com
Christian Höltje commented on Bug JENKINS-37817
 
Re: Pipeline should be able to use hudson.plugins.git.GitSCM getBranches

And FYI: I'm aware that I can approve it via the script permission page; however, I feel this should just work out of the box.

docwhat@gerf.org (JIRA)

unread,
Aug 30, 2016, 12:57:02 PM8/30/16
to jenkinsc...@googlegroups.com

Actually, approving seems to lead down a rat-hole of having to approve a boat-load of things, which isn't acceptable.

docwhat@gerf.org (JIRA)

unread,
Aug 30, 2016, 1:05:01 PM8/30/16
to jenkinsc...@googlegroups.com

Okay, you can't access scm.extensions, scm.doGenerateSubmoduleConfigurations}, nor {{scm.userRemoteConfigs. The same org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException error each time.

What's the right way to modify the SCM options, then?

docwhat@gerf.org (JIRA)

unread,
Aug 30, 2016, 1:39:02 PM8/30/16
to jenkinsc...@googlegroups.com

docwhat@gerf.org (JIRA)

unread,
Aug 30, 2016, 2:02:03 PM8/30/16
to jenkinsc...@googlegroups.com
 
Re: Pipeline should be able to use hudson.plugins.git.GitSCM getBranches

Here is the list of all the methods I had to approve to get this to work:

method hudson.plugins.git.GitSCM getBranches
method hudson.plugins.git.GitSCM getUserRemoteConfigs
method hudson.plugins.git.GitSCM isDoGenerateSubmoduleConfigurations
method hudson.plugins.git.GitSCMBackwardCompatibility getExtensions
staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods plus java.util.List java.lang.Iterable
staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods plus java.util.List java.lang.Object

mark.earl.waite@gmail.com (JIRA)

unread,
Aug 30, 2016, 2:13:04 PM8/30/16
to jenkinsc...@googlegroups.com

mark.earl.waite@gmail.com (JIRA)

unread,
Aug 30, 2016, 2:13:04 PM8/30/16
to jenkinsc...@googlegroups.com
Mark Waite assigned an issue to Unassigned
Change By: Mark Waite
Assignee: Mark Waite

jglick@cloudbees.com (JIRA)

unread,
Sep 9, 2016, 4:58:02 PM9/9/16
to jenkinsc...@googlegroups.com
Jesse Glick resolved as Won't Fix
 

As of a recent change, you should be able to specify the desired extensions directly in the GitSCMSource, avoiding the need to patch scm at all.

Change By: Jesse Glick
Status: Open Resolved
Resolution: Won't Fix

docwhat@gerf.org (JIRA)

unread,
Sep 12, 2016, 8:36:01 PM9/12/16
to jenkinsc...@googlegroups.com
Christian Höltje edited a comment on Bug JENKINS-37817
Okay, you can't access {{scm.extensions}}, {{scm.doGenerateSubmoduleConfigurations} } , nor {{scm.userRemoteConfigs}}.  The same {{org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException}} error each time.


What's the right way to modify the SCM options, then?

docwhat@gerf.org (JIRA)

unread,
Sep 12, 2016, 8:38:01 PM9/12/16
to jenkinsc...@googlegroups.com

What does that mean I put into a Jenkinsfile?

I tried scm.extensions.add([$class: 'CloneOption', noTags: false, reference: '', shallow: true]) but that didn't do anything.

scm itself seems to be a GitSCM object, not a GitSCMSource.

And the pipeline syntax snippets generator doesn't have anything for checkout with scm, only manually specifying everything by hand, which defeats the purpose of using the Github Org Folders plugin (which provides scm for you).

docwhat@gerf.org (JIRA)

unread,
Sep 12, 2016, 8:56:02 PM9/12/16
to jenkinsc...@googlegroups.com
Christian Höltje updated an issue
Change By: Christian Höltje
Environment: Jenkins 2.7. 2 3
Git-Plugin:
2 3 . 0.0
GitHub Organization Folder Plugin: 1.
5
GitHub plugin: 1
. 3 21.1
Reply all
Reply to author
Forward
0 new messages