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

Editable E-Mail Notification PreSend not loading CLASSPATH

    Details

    • Similar Issues:

      Description

      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.

        Attachments

          Activity

          jason_mcd Jason McDonald created issue -
          Hide
          slide_o_mix Alex Earl added a comment -

          Can you provide an example of what you are doing?

          Show
          slide_o_mix Alex Earl added a comment - Can you provide an example of what you are doing?
          Hide
          jason_mcd 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!

          Show
          jason_mcd 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!
          Hide
          slide_o_mix Alex Earl added a comment -

          Can you post the error you are getting?

          Show
          slide_o_mix Alex Earl added a comment - Can you post the error you are getting?
          Hide
          jason_mcd 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

          Show
          jason_mcd 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
          Hide
          slide_o_mix Alex Earl added a comment -

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

          Show
          slide_o_mix Alex Earl added a comment - Are you adding the classpath at the project level, or in the local config?
          Hide
          slide_o_mix 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.

          Show
          slide_o_mix 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.
          Hide
          jason_mcd 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.

          Show
          jason_mcd 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.
          Hide
          scm_issue_link 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.

          Show
          scm_issue_link 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.
          slide_o_mix Alex Earl made changes -
          Field Original Value New Value
          Status Open [ 1 ] In Progress [ 3 ]
          Hide
          slide_o_mix Alex Earl added a comment -

          Added expansion of variables to classpath resolution.

          Show
          slide_o_mix Alex Earl added a comment - Added expansion of variables to classpath resolution.
          slide_o_mix Alex Earl made changes -
          Status In Progress [ 3 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          rtyler R. Tyler Croy made changes -
          Workflow JNJira [ 162860 ] JNJira + In-Review [ 197058 ]

            People

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

              Dates

              • Created:
                Updated:
                Resolved: