本文介绍了如何使用Azure Pipeline在Jmeter中传递变量组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在链接到Azure Key Vault机密的azure管道中使用变量"组.该机密将用于连接到sql数据库.

I need to use the Variable group in the azure pipeline that links to Azure Key Vault secret. The secret will be used to connect to a sql database.

在Azure Pipeline中以构建方式运行它时,是否可以将这个变量组传递/使用到Jmeter.jmx?

Is there a way that I can pass/use this variable group to Jmeter.jmx when running it as build in the Azure Pipeline?

这是我在运行Jmeter.jmx负载测试文件时使用的模板.

This is the template that I used when running the Jmeter.jmx load test file.

> https://docs.microsoft.com/zh-cn/azure/devops/pipelines/tasks/test/run-jmeter-load-test?view=azure-devops#open-source

推荐答案

由于管道任务中没有这样的选项或复选框可以直接实现将变量值传递给.jmx文件,因此可以使用替换令牌任务以实现被替换的参数值.

Since there no such option or checkbox in task of pipeline to directly achieve pass variable value to .jmx file, you can use the Replace token task to achieve the Parameter value replaced.

  • 首先使用Azure Key Vault任务下载相关机密.
  • 添加替换令牌任务(注释:在测试步骤之前添加此任务因此测试步骤可以使用.jmx文件执行接收到该值),然后指定目标文件
  • Add Replace Token task(note: add this task before test stepthus the test step can executed with the .jmx file which hasreceived the value), then specify the target files
  • 然后将.jmx文件中的变量配置为#{parameter name}#格式:
  • Then configure the variable in .jmx file with the format #{parameter name}#:

注意:在.jmx文件中定义的参数名称应该与在Azure密钥保管库中的变量名称相同.否则,该参数将无法从变量获取值.

Note: The parameter name which defined in the .jmx file should same with the variable name which in Azure key Vault. Otherwise, the parameter could not get the value from variable.

这是本地代理中存在的我的源文件,您可以看到该值已成功传递:

This is my source files which exists in my agent locally, you can see that the value was passed successfully:

这篇关于如何使用Azure Pipeline在Jmeter中传递变量组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-18 21:49