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

问题描述

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

在 Azure Pipeline 中将它作为构建运行时,有没有办法可以将此变量组传递/使用到 Jmeter.jmx?

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

  • 添加替换令牌任务(注意:在测试步骤之前添加此任务因此测试步骤可以使用 .jmx 文件执行,该文件具有收到值),然后指定目标文件
  • 然后在.jmx文件中配置变量,格式为#{parameter name}#:

注意: .jmx 文件中定义的参数名称应该与 Azure Key Vault 中的变量名称相同.否则,参数无法从变量中获取值.

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

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.

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

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

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

解决方案

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.

  • Use Azure Key Vault task to download the relevant secrets firstly.
  • 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
  • Then configure the variable in .jmx file with the format #{parameter name}#:

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