Forum Discussion

ankushpoly13's avatar
ankushpoly13
New Contributor
5 years ago

How to use 1 groovy script value to another groovy script

How to use 1 groovy script value to another groovy script ?

6 Replies

  • richie's avatar
    richie
    Community Hero
    Hi ankushpoly13

    That description of what you need is going to need a lot more detail before anyone is gonna be able to help out!

    People are going to need to understand your use case, what your groovy scripts are doing etc.

    If you need to pass a value from one script to another it could be fairly simple (depending on what your scripts are doing), but no one's going to be able to help until you provide a lot more info i'd expect!

    Cheers,

    Rich
  • ankushpoly13 ,

     

    There are several ways to use the value of one groovy script to another groovy but before answering i need to know what kind of value you need to use or transfer via one groovy to another.

     

  • nmrao's avatar
    nmrao
    Champion Level 3
    Another basic thing.

    Does it really require two groovy script test steps in first place? Can't the logic be done in single step where you don't land into problem itself?

    If you can't avoid two steps, then save the value into custom property and access it in the other script.
    • groovyguy's avatar
      groovyguy
      Champion Level 1

      nmrao brings up a good point and that's typically how I handle having to share results of a groovy script across tests. Store it as a property and use property expansion to reference it.