Hi there,

I'd like to implement a groovy script which checks out the contents of a 
single file from the SCM(be it Git,SVN...). I took a look into the insides 
of the Branch Source plugin to see how it gets only the Jenkinsfile, but 
still haven't gotten anything from it. I've also seen that, in the SCM API 
plugin the abstract class SCMFileSystem is able to retrieve a SCMFile, from 
which you can retrieve the contents. So I began writing a script to try and 
checkout something from GitHub with classes from the GitHub branch source 
implementation:


import jenkins.plugins.git.AbstractGitSCMSource;
import jenkins.plugins.git.AbstractGitSCMSource.SCMRevisionImpl;
import org.jenkinsci.plugins.github_branch_source.BranchSCMHead;

def revision = new AbstractGitSCMSource.SCMRevisionImpl(new BranchSCMHead(
"master"),"861fd864153dff3bd5e761b42be5ad63cc4a95a1");


Unfortunately an exception is thrown saying that "Scripts are not permitted 
to use new":

org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts 
not permitted to use new 
org.jenkinsci.plugins.github_branch_source.BranchSCMHead java.lang.String
...


And I see that "new String()" may be blacklisted just like in this issue. 
<https://issues.jenkins-ci.org/browse/JENKINS-34638> 
I'd like to know if checking a single file from SCM is possible and if this 
is the right approach.

Any help would be appreciated. Thank you for your attention!


-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/3ca83c6a-60e4-4794-9bbb-336936afdfe0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to