Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
User Journal

Journal Greyfox's Journal: Jmeter Does Not Have Access to Environment Variables?

Maybe not, but if you "set > workspace/job.properties" and pass your Job Path in to jmeter as a property, you can read the damn things back out with a beanshell sampler later on. Handy for grabbing variables from your Hudson parameterized build. Just don't forget to define JobPath as ${__P(JobPath,)} in your user defined variables.

import java.io.BufferedReader;

String response = "";

try {
      BufferedReader in = new BufferedReader(new FileReader("${JobPath}/workspace/job.properties"));
      String nextLine = in.readLine();
      while(null != nextLine) {
              String[] keyval = nextLine.split("=");
              if (2 == keyval.length) {
                    vars.put(keyval[0],${__eval(keyval[1])});
              }
              response = response + nextLine + "\n";
              nextLine = in.readLine();
        }
} catch (java.io.FileNotFoundException e) {
        response = "Unable to locate properties file for environment; using defaults.";
}

SampleResult.setResponseData(response);

This discussion has been archived. No new comments can be posted.

Jmeter Does Not Have Access to Environment Variables?

Comments Filter:

The Tao is like a glob pattern: used but never used up. It is like the extern void: filled with infinite possibilities.

Working...