1

I want to execute my Jmeter scripts based on the environment parameter passed on the command line. I have two environments Env1 and Env2, So if I pass environment parameter as Env1 on command line then the Jmeter scripts should execute for the URL configured for environment 1 and so on.

Can anyone help me with this work around?

Please note, I have implemented my Jmeter scripts using Maven project structure.

Nahor
  • 83
  • 1
  • 7

1 Answers1

1
  1. In your pom.xml file define a property, for example environment

    <properties>
      <environment>Env1</environment>
    </properties>
    

    this way you will be able to pass the environment property value via -D command-line argument

  2. In <propertiesUser> section of the JMeter Maven Plugin define the same environment property:

    <propertiesUser>
       <environment>${users}</environment>
    </propertiesUser>
    

    this way you will be able to read the property value via __P() function in your JMeter script like:

    ${__P(environment,)}
    

Above information should be sufficient for implementing your scenario, at least you can pass the URL directly via this property.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133