[JIRA] (JENKINS-55479) Using workspace classes from multiple DSL scripts fails

1 view
Skip to first unread message

roman.donchenko@intel.com (JIRA)

unread,
Jan 9, 2019, 8:31:02 AM1/9/19
to jenkinsc...@googlegroups.com
Roman Donchenko created an issue
 
Jenkins / Bug JENKINS-55479
Using workspace classes from multiple DSL scripts fails
Issue Type: Bug Bug
Assignee: Daniel Spilker
Components: job-dsl-plugin
Created: 2019-01-09 13:30
Environment: Jenkins 2.150.1
Job DSL plugin 1.71
Priority: Major Major
Reporter: Roman Donchenko

Create a pipeline job with the following script:

node('master') {
 writeFile file: 'a.groovy', text: 'new C()'
 writeFile file: 'b.groovy', text: 'new C()'
 writeFile file: 'C.groovy', text: 'class C {}'
 jobDsl targets: 'a.groovy,b.groovy', sandbox: true
}

Add appropriate authorization to the job and run it. It will fail with output like this:

Started by user [...]
Running as [...]
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/test
[Pipeline] {
[Pipeline] writeFile
[Pipeline] writeFile
[Pipeline] writeFile
[Pipeline] jobDsl
Processing DSL script a.groovy
Processing DSL script b.groovy
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: Scripts not permitted to use new C
Finished: FAILURE

This only happens if multiple DSL scripts are used. If you change the jobDsl step to only run a.groovy, it works fine.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

mail@daniel-spilker.com (JIRA)

unread,
Jan 9, 2019, 4:24:02 PM1/9/19
to jenkinsc...@googlegroups.com
Daniel Spilker updated an issue
Change By: Daniel Spilker
Component/s: script-security-plugin

mail@daniel-spilker.com (JIRA)

unread,
Jan 9, 2019, 4:28:02 PM1/9/19
to jenkinsc...@googlegroups.com
Daniel Spilker commented on Bug JENKINS-55479
 
Re: Using workspace classes from multiple DSL scripts fails

PR: https://github.com/jenkinsci/job-dsl-plugin/pull/1156

I think the problem is that Job DSL re-uses the GroovyShell object, but the Script Security plugin creates a new sandbox for each script. Currently the Script Security does not provide an API to run multiple scripts in the same sandbox.

To fix this I had to disable the GroovyShell cache. Running many scripts in sandbox mode will be slower.

mail@daniel-spilker.com (JIRA)

unread,
Mar 22, 2019, 10:57:02 AM3/22/19
to jenkinsc...@googlegroups.com
Change By: Daniel Spilker
Status: Open Fixed but Unreleased
Resolution: Fixed
Released As: Job DSL 1.72

mail@daniel-spilker.com (JIRA)

unread,
Mar 11, 2020, 9:09:02 AM3/11/20
to jenkinsc...@googlegroups.com
Change By: Daniel Spilker
Status: Fixed but Unreleased Closed
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages