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

Allow importing local classes when the build is running as an administrator

      I have Authorize Plugin installed and I'm running the build as an admin user (without that it would just fail with ERROR: script not yet approved for use).

      I'm trying to run a job-dsl step with files checked out from SCM.

      It fails when trying to import another class defined in the same directory:

      /var/lib/jenkins/jobs/CFS Pipeline Seed/workspace/avalonPipeline.groovy: 3: unable to resolve class JobBuilder
       @ line 3, column 1.
         import JobBuilder
         ^

      There is a JobBuilder.groovy file in the workspace.

      I was able to run the job only by disabling "Enable script security for Job DSL scripts" option in the global security settings.

          [JENKINS-43726] Allow importing local classes when the build is running as an administrator

          Jakub Bochenski created issue -
          Jakub Bochenski made changes -
          Description Original: I have Authorize Plugin installed and I'm running the build as an admin user (without that it would just fail saying the script needs approval).

          I'm trying to run a job-dsl step with files checked out from SCM.

          It fails when trying to import another class defined in the same directory:
          {code:java}
          /var/lib/jenkins/jobs/CFS Pipeline Seed/workspace/avalonPipeline.groovy: 3: unable to resolve class JobBuilder
           @ line 3, column 1.
             import JobBuilder
             ^{code}
          There is a {{JobBuilder.groovy}} file in the workspace.

          I was able to run the job only by disabling "Enable script security for Job DSL scripts" option in the global security settings.
          New: I have Authorize Plugin installed and I'm running the build as an admin user (without that it would just fail with {{ERROR: script not yet approved for use}}).

          I'm trying to run a job-dsl step with files checked out from SCM.

          It fails when trying to import another class defined in the same directory:
          {code:java}
          /var/lib/jenkins/jobs/CFS Pipeline Seed/workspace/avalonPipeline.groovy: 3: unable to resolve class JobBuilder
           @ line 3, column 1.
             import JobBuilder
             ^{code}
          There is a {{JobBuilder.groovy}} file in the workspace.

          I was able to run the job only by disabling "Enable script security for Job DSL scripts" option in the global security settings.
          Daniel Spilker made changes -
          Resolution New: Not A Defect [ 7 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]
          Jakub Bochenski made changes -
          Resolution Original: Not A Defect [ 7 ]
          Status Original: Resolved [ 5 ] New: Reopened [ 4 ]
          Jakub Bochenski made changes -
          Issue Type Original: Bug [ 1 ] New: Improvement [ 4 ]
          Priority Original: Blocker [ 1 ] New: Critical [ 2 ]
          Summary Original: Script security broke importing local classes New: Allow importing local classes when the build is running as an administrator
          Jakub Bochenski made changes -
          Comment [ [~daspilker] I'm not sure what are you referring to.
          I tried to start a discussion on the mailng list as you suggested but got no responses.

          What I don't get at this point is why it's possible to import classes from Jenkinsfiles (https://jenkins.io/doc/book/pipeline/shared-libraries/) even with security ON, but not from Job-DSL scripts. ]
          Jamie Tanna made changes -
          Assignee Original: Daniel Spilker [ daspilker ] New: Jamie Tanna [ jamietanna ]

            jamietanna Jamie Tanna
            jbochenski Jakub Bochenski
            Votes:
            6 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated: