Reading Environment Variable values in Jmeter

Viewed 17364

I want to parametrize the testdata path, result path, server and port by defining them in environment variable.

I was able to achieve this to certain extent with System.getenv("Jmeter_Result") using it in BeanShell processor. But I need to use configuration element to fetch the value.

Can you kindly suggest.I am using Jmeter 3.1.

3 Answers

According to https://jmeter.apache.org/usermanual/functions.html#what_can_do, ${__BeanShell( ... )} may also help you on this issue.

For instance, one of our APIs needs OAuth2 authentication, and what I did was:

- Thread Group
    - User Defined Variables
        client_id     = ${__BeanShell( System.getenv("client_id") )}
        client_secret = ${__BeanShell( System.getenv("client_secret") )}
    - Once Only Controller
        - OAuth2 HTTP Request
    - API HTTP Request
Related