Ask a Question

Reg: Unable to run my Groovy script from Jenkins.

SOLVED
SumitM
Occasional Contributor

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

5 REPLIES 5
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.

 


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
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.

 

 


Olga Terentieva
SmartBear Assistant Community Manager

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?

Beginner
Occasional Contributor

I have the exact same issue..

 

Did you happen to find any solution for this?

Radford
Super Contributor

@Beginner, it's probably best to start new topics rather than post to old ones, especially when they are marked as solved, I amost skipped over this and didn't read because it was marked as solved.

 

Anyway...

 

The script library can be set at a global level, or on a per project level. If setting at a per project level you can use one of the two dynamic references as part of your path:

 

  • ${projectDir} – The path to the folder the project is stored in.
  • ${workspaceDir} – The path to the folder containing the workspace file. The default ReadyAPI workspace is stored in the C:\Users\<username>\ folder.

 

 

 

cancel
Showing results for 
Search instead for 
Did you mean: