| 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. |