Forum Discussion

Cleo-Juniper's avatar
New Contributor
8 months ago

How do you reuse your ReadyAPI Groovy scripts if you want to run tests in a pipeline?

"Create custom Groovy classes, embed your reusable Groovy scripts into their methods, save them as separate files with the .groovy extension and voila - your Script Library is ready. You just need to point ReadyAPI where to find it (Preferences > ReadyAPI > Script library). If you change anything in those external classes, ReadyAPI will detect this and reload the classes automatically."


Does this work if you're running the tests in a pipeline or from a commandline on your local machine?  How would you point your commandline run script to the groovy script library?  And where would you recommend keeping this library if it is being used in multiple projects?  We have multiple projects but kept within the same repo (not using git's integration with readyapi, as this doesn't allow for multiple projects in the same repo).  Ideally what I want is for someone to pull down the tests from git and then just open up readyApi and be able to run the tests.  I don't want them to have to do lots of configuration to be able to run the tests.

2 Replies

  • nmrao's avatar
    Champion Level 3

    Alternatively, create classes / methods in groovy or java instead of script files.

    Compile them and create a jar file and place it under ReadyAPI_HOME/bin/ext directory.


  • KarelHusa's avatar
    Champion Level 2


    if your external Groovy/Java code needs to be shared amongst all tests, you can place it in a separate Git repo.


    At your local computer, checkout the repo and configure your ReadyAPI to point into that directory.


    In the pipeline, you need to setup ReadyAPI. Checkout of the shared code repo would be part of this ReadyAPI setup (probably as a ready-made container). So in each test pipeline you won't need to do extra work.