-
Bug
-
Resolution: Not A Defect
-
Major
-
None
-
Master: Atomic CentOS
Slave: Windows Server 2012 R2 x64
I have a class in a pipeline shared library (which is stored in a deployed Github repository):
package com.xxx class ArtifactoryPublisher implements Serializable { def script def host ArtifactoryPublisher(script, host) { this.script = script this.host = host } def push(feed, pattern = "*.nupkg") { def artifactory = Artifactory.server this.host def uploadSpec = """{ "files": [ { "pattern": "$pattern", "target": "$feed" } ] }""" def buildInfo = artifactory.upload(uploadSpec) artifactory.publishBuildInfo(buildInfo) } }
When I try to instantiate this in a Jenkinsfile:
def apub = new ArtifactoryPublisher('art01')
I get this:
org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: unclassified new com.xxx.ArtifactoryPublisher java.lang.String at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onNewInstance(SandboxInterceptor.java:126) at org.kohsuke.groovy.sandbox.impl.Checker$3.call(Checker.java:191) at org.kohsuke.groovy.sandbox.impl.Checker.checkedConstructor(Checker.java:188) at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.constructorCall(SandboxInvoker.java:20) at WorkflowScript.run(WorkflowScript:78)
However, it does not show up as a pending script approval.
PS it is possible to create other objects from shared libraries, e.g.
def slack = new Slack(this, mySlack.team, mySlack.channel)
[JENKINS-43041] Cannot create a new instance of a pipeline shared library class
Description |
Original:
I have a class in a pipeline shared library (which is stored in a deployed Github repository): {code:java} package com.xxx class ArtifactoryPublisher implements Serializable { def script def host ArtifactoryPublisher(script, host) { this.script = script this.host = host } def push(feed, pattern = "*.nupkg") { def artifactory = Artifactory.server this.host def uploadSpec = """{ "files": [ { "pattern": "$pattern", "target": "$feed" } ] }""" def buildInfo = artifactory.upload(uploadSpec) artifactory.publishBuildInfo(buildInfo) } } {code} When I try to instantiate this in a Jenkinsfile: {code:java} def apub = new ArtifactoryPublisher('art01') {code} I get this: {noformat} org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: unclassified new com.xxx.ArtifactoryPublisher java.lang.String at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onNewInstance(SandboxInterceptor.java:126) at org.kohsuke.groovy.sandbox.impl.Checker$3.call(Checker.java:191) at org.kohsuke.groovy.sandbox.impl.Checker.checkedConstructor(Checker.java:188) at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.constructorCall(SandboxInvoker.java:20) at WorkflowScript.run(WorkflowScript:78){noformat} However, it does not show up as a pending script approval. |
New:
I have a class in a pipeline shared library (which is stored in a deployed Github repository): {code:java} package com.xxx class ArtifactoryPublisher implements Serializable { def script def host ArtifactoryPublisher(script, host) { this.script = script this.host = host } def push(feed, pattern = "*.nupkg") { def artifactory = Artifactory.server this.host def uploadSpec = """{ "files": [ { "pattern": "$pattern", "target": "$feed" } ] }""" def buildInfo = artifactory.upload(uploadSpec) artifactory.publishBuildInfo(buildInfo) } } {code} When I try to instantiate this in a Jenkinsfile: {code:java} def apub = new ArtifactoryPublisher('art01') {code} I get this: {noformat} org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: unclassified new com.xxx.ArtifactoryPublisher java.lang.String at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onNewInstance(SandboxInterceptor.java:126) at org.kohsuke.groovy.sandbox.impl.Checker$3.call(Checker.java:191) at org.kohsuke.groovy.sandbox.impl.Checker.checkedConstructor(Checker.java:188) at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.constructorCall(SandboxInvoker.java:20) at WorkflowScript.run(WorkflowScript:78){noformat} However, it does not show up as a pending script approval. PS it is possible to create other objects from shared libraries, e.g. {code:java} def slack = new Slack(this, mySlack.team, mySlack.channel) {code} |
Component/s | Original: pipeline [ 21692 ] |
Resolution | New: Not A Defect [ 7 ] | |
Status | Original: Open [ 1 ] | New: Resolved [ 5 ] |