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

Editable E-Mail Notification PreSend not loading CLASSPATH

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • email-ext-plugin
    • Jenkins 1.610, Email-EXT 2.39.3

      Loading libs described in the field: 'Additional Groovy ClassPath' does not seem to be working. I'm trying to add libs(jars) to the classpath which are stored in the project's ${WORKSPACE}. Execute System Groovy Script classpath var handles this no problem.

          [JENKINS-28145] Editable E-Mail Notification PreSend not loading CLASSPATH

          Alex Earl added a comment -

          Can you provide an example of what you are doing?

          Alex Earl added a comment - Can you provide an example of what you are doing?

          Thanks for the quick response!

          I'm trying to use RESTClient. Example:

          def http = new RESTClient('https://api.hipchat.com')
          http.post(
          path : '/v1/rooms/message',
          body : postBody,
          query : query,
          requestContentType : URLENC )

          The way I'm able to use it with Execute System Groovy Script is I execute a gradle build to pull the dependencies and Then I add: '${WORKSPACE}/libs/http-builder-0.7.2.jar:${WORKSPACE}/libs/xml-resolver-1.2.jar' to the System groovy script classpath. I can then import both: 'import groovyx.net.http.ContentType,
          import groovyx.net.http.RESTClient'.

          When I try the same thing in the E-Mail EXT PreSend script (Add the 2 jars to the classpath, add the imports) I get unable to resolve. I tried using @Grab but I got an IVY error (I believe that's a whole other issue).

          Thanks for all the help!

          Jason McDonald added a comment - Thanks for the quick response! I'm trying to use RESTClient. Example: def http = new RESTClient('https://api.hipchat.com') http.post( path : '/v1/rooms/message', body : postBody, query : query, requestContentType : URLENC ) The way I'm able to use it with Execute System Groovy Script is I execute a gradle build to pull the dependencies and Then I add: '${WORKSPACE}/libs/http-builder-0.7.2.jar:${WORKSPACE}/libs/xml-resolver-1.2.jar' to the System groovy script classpath. I can then import both: 'import groovyx.net.http.ContentType, import groovyx.net.http.RESTClient'. When I try the same thing in the E-Mail EXT PreSend script (Add the 2 jars to the classpath, add the imports) I get unable to resolve. I tried using @Grab but I got an IVY error (I believe that's a whole other issue). Thanks for all the help!

          Alex Earl added a comment -

          Can you post the error you are getting?

          Alex Earl added a comment - Can you post the error you are getting?

          org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
          Script1.groovy: 2: unable to resolve class groovyx.net.http.RESTClient
          @ line 2, column 1.
          import groovyx.net.http.RESTClient
          ^

          Script1.groovy: 1: unable to resolve class groovyx.net.http.ContentType
          @ line 1, column 1.
          import groovyx.net.http.ContentType

          Jason McDonald added a comment - org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script1.groovy: 2: unable to resolve class groovyx.net.http.RESTClient @ line 2, column 1. import groovyx.net.http.RESTClient ^ Script1.groovy: 1: unable to resolve class groovyx.net.http.ContentType @ line 1, column 1. import groovyx.net.http.ContentType

          Alex Earl added a comment -

          Are you adding the classpath at the project level, or in the local config?

          Alex Earl added a comment - Are you adding the classpath at the project level, or in the local config?

          Alex Earl added a comment -

          I think the problem is that the classpath is never resolved for environment variables, so ${WORKSPACE} isn't getting replaced with the path to the workspace. I'll play around with this some more and verify that is what is happening.

          Alex Earl added a comment - I think the problem is that the classpath is never resolved for environment variables, so ${WORKSPACE} isn't getting replaced with the path to the workspace. I'll play around with this some more and verify that is what is happening.

          Thank you. I haven't tried the full path either. I'll give it a go also, but it seems the most logical explanation.

          Jason McDonald added a comment - Thank you. I haven't tried the full path either. I'll give it a go also, but it seems the most logical explanation.

          Code changed in jenkins
          User: Alex Earl
          Path:
          src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java
          src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherTest.java
          http://jenkins-ci.org/commit/email-ext-plugin/1a52cc262fda8de69128cc277bb03d6c8fe3b7de
          Log:
          Fix JENKINS-28145

          Added resolution of variables to the classpath expansion.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Alex Earl Path: src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherTest.java http://jenkins-ci.org/commit/email-ext-plugin/1a52cc262fda8de69128cc277bb03d6c8fe3b7de Log: Fix JENKINS-28145 Added resolution of variables to the classpath expansion.

          Alex Earl added a comment -

          Added expansion of variables to classpath resolution.

          Alex Earl added a comment - Added expansion of variables to classpath resolution.

            slide_o_mix Alex Earl
            jason_mcd Jason McDonald
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: