Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-55479

Using workspace classes from multiple DSL scripts fails

XMLWordPrintable

    • Job DSL 1.72

      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.

            daspilker Daniel Spilker
            rdonchen_intel Roman Donchenko
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: