Forum Discussion

stef's avatar
stef
Occasional Contributor
8 years ago

How to retrieve the selected environment from the command line (-E) in a groovy script?

Hi all,

 

I know how to retrieve the active environment from the project (UI) using this solution.

However I want to know how to get the environment which is provided as a commandline parameter (e.g. when started via soaprunner.bat) like :

-ELOCAL_ENV

Is this possible with groovy scripting ?

7 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    It is a bit confusing.

    The link you mentioned has step to retrieve the environment name using groovy only.

    And the command line option you mentioned is to set the environment.

    So, do not understand the problem.
    • stef's avatar
      stef
      Occasional Contributor

      Dear Rao,

       

      When the SoapRunner.bat is used to run a test, the environment can be supplied using that -E command line parameter.

      Now inside my test, I want to use a groovy script to retrieve the value for this -E command line parameter so that I can determine the environment. This environment is then used by the script script to do some specific business logic. (I don't want to use the saved selected environment from the project, but I want to use this value.)

  • stef's avatar
    stef
    Occasional Contributor
    Indeed. TestRunner.bat

    Sorry for the confusion.
    • nmrao's avatar
      nmrao
      Champion Level 3
      Ok. testrunner will inject the envrionment name that you needed from command line.

      And you already know how to access environment name in the groovy script based on the link you provided in the question i.e.,
      testRunner.testCase.project.getActiveEnvironment().name

      Hope it is clear and no confusion.
      • stef's avatar
        stef
        Occasional Contributor

        I don't think that statement

         

        testRunner.testCase.project.getActiveEnvironment().name

        is not correct.

         

        I have the feeling that the value saved in the project-url is overwrting the value on the command-line.

        I'll do some more testing.