How to make the target of the artillery yml file configurable / variable?

246 Views Asked by At
config:
  target: "https://some-site.com"

This my current setup. the target is static. I want to make it variable, either through a command line argument or environment argument.

For Example:

config:
  target: "{{ target_site }}"
1

There are 1 best solutions below

0
bernardobridge On BEST ANSWER

Three options:

Option 1. processEnvironment

Use $processEnvironment to get a variable from an environment variable:

config:
  target: "{{ $processEnvironment.TARGET_URL }}"

And run with TARGET_URL=https://some-site.com artillery run scenario.yml


Option 2. --variables

Define your YAML like this:

config:
  target: "{{ targetUrl }}"

And then run your scenario by passing in the targetUrl variable:

artillery run scenario.yml --variables '{ "targetUrl": "https://some-site.com" }'


Option 3. --dotenv

Create a .env file with the URL:

TARGET_URL=https://some-site.com

Then, create your scenario as in the first option.

Finally, run your scenario with:

artillery run scenario.yml --dotenv <path_to_dotenv_file>