我有一个邮差集合,其中端点指向一个用于上传执行的物理文件。我将其配置为在Azure管道中运行,并且需要使用Azure存储库中的文件路径。我正在使用纽曼CLI在Azure中运行此命令。
是邮差集合代码片段。我更改了文件的路径(以前在c: drive上),现在使用Azure repo中的位置
item": [
{
"name": "GameInstall",
"protocolProfileBehavior": {
"disabledSystemHeaders": {}
},
"request": {
"auth": {
"type": "apikey",
"apikey": [
{
"key": "value",
"value": "Bearer eyJraAcg",
"type": "string"
},
{
"key": "key",
"value": "Authorization",
"type": "string"
}
]
},
"method": "POST",
"header": [
{
"key": "x-api-key",
"value": "ee32-4ffb-424e-b8f0-46c0768",
"type": "text"
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "gamePresetFormFile",
"type": "file",
"src": "$(System.DefaultWorkingDirectory)/test/AxiomAdministratorCore.DataGeneration.Tests/DataGeneration.Tests/GameInstall/11016_50300_HTML5Desktop-FeatureSlot-BurningDesire.zip
},
{
"key": "gameContentFormFile",
"type": "file",
"src": "$(System.DefaultWorkingDirectory)/test/AxiomAdministratorCore.DataGeneration.Tests/DataGeneration.Tests/GameInstall/BurningDesire.zip"
}
]
},
在Azure中,我将管道任务设置为纽曼运行命令,执行以下操作:用户"C: 制造 AppData npm newman"漫游;运行测试(Release.PrimaryArtifactSourceAlias)美元 CoreDataGeneration.Tests DataGeneration.Tests 邮差 GameInstalls.postman_collection。test core . dataggeneration . tests dataggeneration . tests PostMan axiom_test .postman_environment. json -e $(Release.PrimaryArtifactSourceAlias)json -r cli,junitfull——reporter-junitfull-export $(Release.PrimaryArtifactSourceAlias)report.xml
纽曼管道
当任务运行时,我得到这个错误:
GameInstall_BurningDesire
┌
│ 'Form param `gamePresetFormFile`, file load error: "$(
│ System.DefaultWorkingDirectory)/test/AxiomAdministrato
│ rCore.DataGeneration.Tests/DataGeneration.Tests/GameIn
│ stall/11016_50300_HTML5Desktop-FeatureSlot-BurningDesi
│ re.zip", no such file'
│ 'Form param `gameContentFormFile`, file load error: "$
│ (System.DefaultWorkingDirectory)/test/AxiomAdministrat
│ orCore.DataGeneration.Tests/DataGeneration.Tests/GameI
│ nstall/BurningDesire.zip", no such file'
'表单参数
gamePresetFormFile
,文件加载错误:"$(System.DefaultWorkingDirectory)/…
从错误消息来看,JSON文件中的管道变量无法展开。
为了解决这个问题,你可以通过newman run命令将Global变量传递给json文件。
步骤如下:
Step1:在json文件中设置全局变量(格式:{{variablename}}
)
"body": {
"mode": "formdata",
"formdata": [
{
"key": "gamePresetFormFile",
"type": "file",
"src": "{{path2}}"
},
{
"key": "gameContentFormFile",
"type": "file",
"src": "{{path1}}"
}
]
步骤2:添加参数:--global-var "path1=$(System.DefaultWorkingDirectory)/test/AxiomAdministratorCore.DataGeneration.Tests/DataGeneration.Tests/GameInstall/11016_50300_HTML5Desktop-FeatureSlot-BurningDesire.zip"
。
例如:
newman run xxx.json --global-var "path1=path" --global-var "path2=path" --reporters cli,junit --reporter-junit-export ResultsjunitReport.xml