You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何让Artillery YAML文件的target配置项支持变量化/可配置?

配置动态Target变量的实现方法

你已经将配置修改为模板形式:

config:
  target: "{{ target_site }}"

下面是两种实现变量传入的方式:

命令行参数传入

直接在启动命令中指定参数值,让工具自动替换模板变量:

# 替换为你实际使用的工具命令
your-tool-command --target_site "https://your-target-site.com"

工具会识别配置中的{{ target_site }}占位符,并用命令行传入的值替换它。

环境变量传入

先设置环境变量,再启动工具:

Linux/macOS

export target_site="https://your-target-site.com"
your-tool-command

Windows(PowerShell)

$env:target_site="https://your-target-site.com"
your-tool-command

部分工具对变量大小写敏感,若上述方式不生效,可尝试将环境变量名改为大写TARGET_SITE。

手动模板替换(工具不支持自动渲染时)

如果你的工具本身不支持模板变量解析,可以用脚本预处理配置文件:

# 命令行参数方式
sed "s/{{ target_site }}/$1/g" your-config.yaml > temp-config.yaml && your-tool-command --config temp-config.yaml

# 环境变量方式
sed "s/{{ target_site }}/$target_site/g" your-config.yaml > temp-config.yaml && your-tool-command --config temp-config.yaml

内容的提问来源于stack exchange,提问作者Bear Bile Farming is Torture

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 15:45:56