Jmeter base directory and script variables
Working with Been Shell components
One of the option to work with variables in Jmeter is to use BeanShell components like BeanShell PreProcessor .
Getting JMeter base dir
import org.apache.jmeter.services.FileServer;
String baseDir = FileServer.getFileServer().getBaseDir();
vars.put("baseDir", baseDir);
Getting JMeter’s script location (GUI mode)
import org.apache.jmeter.gui.GuiPackage;
String testPlanFile = GuiPackage.getInstance().getTestPlanFile();
vars.put("testPlanFile", testPlanFile);
Getting JMeter’s script name (non-GUI mode)
import org.apache.jmeter.services.FileServer;
String scriptName = FileServer.getFileServer().getScriptName();
vars.put("scriptName", scriptName);
Using inline function
If you prefer you can get the same using __Beanshell() function as
${__BeanShell(import org.apache.jmeter.services.FileServer; FileServer.getFileServer().getBaseDir())}
and it will return current base directory where it is called. source