Forum Discussion

SumitM's avatar
SumitM
Occasional Contributor
7 years ago

Reg: Unable to run my Groovy script from Jenkins.

Hi,

 

I am unable run my Groovy script from Jenkins. Jenkins Groovy script is unable to resolve imported classes. I have copied the Jar file in ..../<groovy home dir>/lib, ..../jre/lib, ..../<groovy home dir>/bin, ..../jdk/bin, ...../Jenkins/jre/lib and in ....Jenkins/jobs/<my job> folders. Nothing worked. I was able to import other jar files by copying it in .....\Jenkins\jre\lib folder. But, this particular jar is not recognized by Jenkin's Groovy script. And, I am able to run same code using IntelliJ tool using Groovy script, without making any changes.

Sample Code:
------------
import SoapUITools.SUIT

ServiceEndpoint = SUIT.GetServiceEndpoint("56", "73")    // GetServiceEndpoint contains a call to Web service that is hosted on different system

 

Syntax Error in Jenkins Groovy script:
------------------------
startup failed:
Script1.groovy: 2: unable to resolve class SoapUITools.SUIT
@ line 2, column 1.
   import SoapUITools.SUIT

 

I tried, import SoapUITools.*, but did not work.

 

Any help would be appreciated,

 

Thanks

  • Hi SumitM,

     

    By default, ReadyAPI uses script libraries from the <ReadyAPI installation>\bin\scripts folder: https://support.smartbear.com/readyapi/docs/testing/scripts/library.html

    If you run your tests in Jenkins using the default soapui-settings.xml file, testRunner will search for scripts in the <ReadyAPI installation>\bin\scripts folder on the machine where you run your tests.

     

    If you have jar files which you need to use, these files should be placed in the <ReadyAPI installation>\bin\ext folder on the machine where you run your tests.

     

  • Nastya_Khovrina's avatar
    Nastya_Khovrina
    SmartBear Alumni (Retired)

    Hi SumitM,

     

    By default, ReadyAPI uses script libraries from the <ReadyAPI installation>\bin\scripts folder: https://support.smartbear.com/readyapi/docs/testing/scripts/library.html

    If you run your tests in Jenkins using the default soapui-settings.xml file, testRunner will search for scripts in the <ReadyAPI installation>\bin\scripts folder on the machine where you run your tests.

     

    If you have jar files which you need to use, these files should be placed in the <ReadyAPI installation>\bin\ext folder on the machine where you run your tests.

     

    • Olga_T's avatar
      Olga_T
      SmartBear Alumni (Retired)

      Hi all,

      Thanks for the detailed instructions, Anastasia!

       

      SumitM, did the above reply help? If the question was answered, could you please mark the topic as Solved? This makes it easier to find the answer to the question in the future.  
      We are looking forward to your reply.

       

       

      • anavanee's avatar
        anavanee
        Senior Member

        Hi Anastasia,

         

          I have same issue and but I don't want to place my project sepcific groovy library under /bin/script folder. Instead, I am placing it under projectDir\groovy_scripts folder and setting this Script Library path inside my setup Script in project level (below code). While running locally, it calls the functions inside my  script library without any error. but when I try to run it from Jenkins, I see below error

        setup Script

         

        def scriptLibrary = context.expand('${projectDir}')+"\\groovy_scripts"
        log.info "${header} Setting project Groovy script library to "+scriptLibrary
        project.setScriptLibrary(scriptLibrary)

         

        Jenkins Console Error

         

        16:59:18,316 ERROR [SoapUI] An error occurred [startup failed:
        Script1.groovy: 2: unable to resolve class sqlQueryReturnValue
        @ line 2, column 28.
           def sqlQueryReturnValue =  new sqlQueryReturnValue()

         

        Can you help to solve this issue?