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

@Grab Grape support for global post script plugin

      Hi Do we have an option to use third party libraries in global-post-script plugin groovy script.

      I am looking to trigger a rest call using the below libraries from a groovy global script plugin

      import groovyx.net.http.RESTClient
      import groovyx.net.http.HttpResponseException
      import groovyx.net.http.ContentType
      import groovyx.net.http.HTTPBuilder

          [JENKINS-37796] @Grab Grape support for global post script plugin

          Hao CHEN added a comment -

          If you are running your Jenkins in Tomcat, you can place the 3rd party libs into the WEB-INF/lib folder.

          If not... I guess I could add a input box to let you input a folder where you could place the 3rd-party libs.

          Hao CHEN added a comment - If you are running your Jenkins in Tomcat, you can place the 3rd party libs into the WEB-INF/lib folder. If not... I guess I could add a input box to let you input a folder where you could place the 3rd-party libs.

          Hao CHEN added a comment -

          I've changed my mind.
          I decide not to let the user to specify the folder path which would hold the 3rd-party libs. As I think it's reasonable to make it a pre-defined path as $JENKINS_HOME/global-post-script/lib, which indicates it's only for running the groovy script, and it will not get deleted by someone else by accident.

          Checkout this feature in 1.1.3, it might take a few hours for 1.1.3 to be synced to the update center.

          Hao CHEN added a comment - I've changed my mind. I decide not to let the user to specify the folder path which would hold the 3rd-party libs. As I think it's reasonable to make it a pre-defined path as $JENKINS_HOME/global-post-script/lib , which indicates it's only for running the groovy script, and it will not get deleted by someone else by accident. Checkout this feature in 1.1.3, it might take a few hours for 1.1.3 to be synced to the update center.

          Sumesh kk added a comment -

          Hi orctom,

          Thanks much for helping me on this

          I am trying to run the below code

          -------------------------------------------------------
          import groovyx.net.http.HTTPBuilder
          import groovyx.net.http.ContentType
          import groovyx.net.http.Method
          import groovyx.net.http.RESTClient
          def client = new RESTClient( 'http://localhost' )
          println client
          -----------------------------------------------------
          I have added all required JAR files under $JENKINS_HOME/global-post-script/lib

          But when i run the above script trough the plugin i am getting [ERROR] Failed to execute: posthook.groovy, org/apache/http/client/methods/HttpRequestBase error .

          At the same time when i have all these jars added to the .groovy directory under my home directory and tried to run the script manually (running groovy scriptfile.groovy command) its getting executed with the expected result

          Sumesh kk added a comment - Hi orctom , Thanks much for helping me on this I am trying to run the below code ------------------------------------------------------- import groovyx.net.http.HTTPBuilder import groovyx.net.http.ContentType import groovyx.net.http.Method import groovyx.net.http.RESTClient def client = new RESTClient( 'http://localhost' ) println client ----------------------------------------------------- I have added all required JAR files under $JENKINS_HOME/global-post-script/lib But when i run the above script trough the plugin i am getting [ERROR] Failed to execute: posthook.groovy, org/apache/http/client/methods/HttpRequestBase error . At the same time when i have all these jars added to the .groovy directory under my home directory and tried to run the script manually (running groovy scriptfile.groovy command) its getting executed with the expected result

          Hao CHEN added a comment -

          I added jars list almost the same with yours, and the script works just fine, it printed out the RESTClient instance.

          Checkout your jenkins_home/lib folder if there're any httpclient jars, and your code has nothing to do with org/apache/http/client/methods/HttpRequestBase, I don't understand why it's throwing exceptions about this class.

          Is that all your code?

          Hao CHEN added a comment - I added jars list almost the same with yours, and the script works just fine, it printed out the RESTClient instance. Checkout your jenkins_home/lib folder if there're any httpclient jars, and your code has nothing to do with org/apache/http/client/methods/HttpRequestBase, I don't understand why it's throwing exceptions about this class. Is that all your code?

          Sumesh kk added a comment -

          Aaaah after days of troubleshooting i can see that it is working today
          I uninstalled the plugin deleted the lib folder .Re installed the plugin and then re created the lib folder .Added the jars back and it just started working

          Sumesh kk added a comment - Aaaah after days of troubleshooting i can see that it is working today I uninstalled the plugin deleted the lib folder .Re installed the plugin and then re created the lib folder .Added the jars back and it just started working

            sumeshkanayi Sumesh kk
            sumeshkanayi Sumesh kk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: