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

Groovy code in classpath no longer respected

    Details

    • Similar Issues:

      Description

      It appears since the last two releases, my utility class no longer resolves if I they are in my classpath, which I stipulate vis class path on the jobDsl step.

      The utility class is just a groovy file with one class:
      https://github.com/hypergig/robo-jenkins/blob/master/robo-jenkins/usr/share/jenkins/userContent/meta_jobs/libs/robo/RoboUtil.groovy

      I use to be able to import it in my seed jobs, but it no longer works:

      ERROR: startup failed:
      /var/jenkins_home/workspace/seed/meta_jobs/seed/seed.groovy: 3: unable to resolve class robo.RoboUtil
       @ line 3, column 1.
         import robo.RoboUtil
         ^
      

      I am pretty sure this is due to this change:

      Use Groovy Shell instead of Groovy Script Engine to run DSL scripts, see Migration (#976)

      https://github.com/jenkinsci/job-dsl-plugin/wiki#release-notes

      But I am not sure... I don't fully understand what it means to use the shell over the engine.

        Attachments

          Activity

          Hide
          daspilker Daniel Spilker added a comment -

          Is this your seed job config? https://github.com/hypergig/robo-jenkins/blob/master/robo-jenkins/usr/share/jenkins/seed.xml

          You can't use meta_jobs/libs/** to add Groovy files to the classpath. That was just happening by accident I guess. You need to add the directory of the root package instead, e.g. meta_jobs/libs. If you use any JARs, you need a second entry for those, e.g. meta_jobs/libs/*.jar.

          Show
          daspilker Daniel Spilker added a comment - Is this your seed job config? https://github.com/hypergig/robo-jenkins/blob/master/robo-jenkins/usr/share/jenkins/seed.xml You can't use meta_jobs/libs/** to add Groovy files to the classpath. That was just happening by accident I guess. You need to add the directory of the root package instead, e.g. meta_jobs/libs . If you use any JARs, you need a second entry for those, e.g. meta_jobs/libs/*.jar .
          Hide
          hypergig jordan cohen added a comment -

          Daniel Spilker that was it! Thank you!

          Show
          hypergig jordan cohen added a comment - Daniel Spilker that was it! Thank you!
          Show
          hypergig jordan cohen added a comment - https://github.com/hypergig/robo-jenkins/commit/28c5a61ca19e349a0cd0d3730787541bc80d5129 Thanks again
          Hide
          spackard Steven Packard added a comment -

          I'm running into this issue and I can't find a way to resolve this. There is no classpath option in the Process Job DSLs build step anymore in the latest plugin. No value of CLASSPATH in preparing an environment seems to get this working. I have version 1.60 of the Job DSL plugin and version 2.46.1 of Jenkins. Please advise. Thanks.

          Show
          spackard Steven Packard added a comment - I'm running into this issue and I can't find a way to resolve this. There is no classpath option in the Process Job DSLs build step anymore in the latest plugin. No value of CLASSPATH in preparing an environment seems to get this working. I have version 1.60 of the Job DSL plugin and version 2.46.1 of Jenkins. Please advise. Thanks.
          Hide
          daspilker Daniel Spilker added a comment -

          Steven Packard the behavior has changed in 1.60 to address a security vulnerability. See https://github.com/jenkinsci/job-dsl-plugin/wiki/Migration#migrating-to-160

          Show
          daspilker Daniel Spilker added a comment - Steven Packard the behavior has changed in 1.60 to address a security vulnerability. See https://github.com/jenkinsci/job-dsl-plugin/wiki/Migration#migrating-to-160

            People

            • Assignee:
              daspilker Daniel Spilker
              Reporter:
              hypergig jordan cohen
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: