Use Jmeter’s base directory

You can access these variables using Beanshell as follows:

  1. JMeter’s base dir
    String baseDir = FileServer.getFileServer().getBaseDir();
    vars.put("baseDir", baseDir);
  2. JMeter’s script location (GUI mode)
    import org.apache.jmeter.gui.GuiPackage;
    String testPlanFile = GuiPackage.getInstance().getTestPlanFile();
    vars.put("testPlanFile", testPlanFile);
  3. JMeter’s script name (non-GUI mode)
    String scriptName = FileServer.getFileServer().getScriptName();
    vars.put("scriptName", scriptName); 

If you prefer you can get the same using __Beanshell() function as

${__BeanShell(import; FileServer.getFileServer().getBaseDir())}

and it will return current base directory where it is called.


Use Jmeter’s base directory

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s