Dave Brunkow
Dave Brunkow

Reputation: 352

Pass credentials to Jmeter command line

How can one pass credentials to the Jmeter command line to be used as username/password for HTTP Authorization Manager username/password? I'm using Jmeter 5.4.

I need to be able to programmatically pull credentials from a vault or Jenkins credentials and pass to Jmeter. Hard coding or writing to a file is not an option.

Upvotes: 0

Views: 1695

Answers (1)

Dmitri T
Dmitri T

Reputation: 168002

Normal way of parameterizing a JMeter test using external data is:

  1. Use __P() function in the HTTP Authorization Manager like:

    ${__P(username,)}
    

    enter image description here

    it will return the username property value

  2. Pass the username property to JMeter via -J command-line argument like:

    jmeter -Jusername=johndoe -n -t test.jmx ....
    

Another option is reading the value from an environment variable using __groovy() function:

${__groovy(System.getenv('username'),)}

or if you have Custom JMeter Functions plugin installed you can do the same using __env() function

${__env(username,,)}

Upvotes: 1

Related Questions