Shanil
Shanil

Reputation: 1

How do I configure a postman file path to point to a location in Azure repository

I have a postman collection, where the endpoint points to a physical file that is used to upload to execute. I am configuring this to run in Azure pipeline and need to use the file path that is in an azure repository. I am using Newman CLI to run this in Azure.

here is the postman collection snippet. I changed the path of the file (previously on c: drive) to use the location in Azure repo now

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"
                        }
                    ]
                },

In Azure, I setup my pipeline task as a Newman Run command that does this: "C:\Users\Build\AppData\Roaming\npm\newman" run $(Release.PrimaryArtifactSourceAlias)\test\CoreDataGeneration.Tests\DataGeneration.Tests\PostMan\GameInstalls.postman_collection.json -e $(Release.PrimaryArtifactSourceAlias)\test\Core.DataGeneration.Tests\DataGeneration.Tests\PostMan\Axiom-Test.postman_environment.json -r cli,junitfull -- reporter-junitfull-export $(Release.PrimaryArtifactSourceAlias)\report.xml

NewMan Pipeline

I get this error when the task runs:

 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'

Upvotes: 0

Views: 665

Answers (1)

Kevin Lu-MSFT
Kevin Lu-MSFT

Reputation: 35524

'Form param gamePresetFormFile, file load error: "$( System.DefaultWorkingDirectory)/...

From the error message, the pipeline variable in JSON file not able to be expand.

To solve this issue, you can pass the Global variable to the json file via newman run command.

Here are the steps:

Step1: set the Global variable(format: {{variablename}}) in json file

"body": {
                    "mode": "formdata",
                    "formdata": [
                        {
                            "key": "gamePresetFormFile",
                            "type": "file",
                            "src": "{{path2}}"
                        },
                        {
                            "key": "gameContentFormFile",
                            "type": "file",
                            "src": "{{path1}}"
                        }
                    ]

Step2: Add the argument: --global-var "path1=$(System.DefaultWorkingDirectory)/test/AxiomAdministratorCore.DataGeneration.Tests/DataGeneration.Tests/GameInstall/11016_50300_HTML5Desktop-FeatureSlot-BurningDesire.zip" to the command.

For example:

newman run xxx.json --global-var "path1=path" --global-var "path2=path"   --reporters cli,junit --reporter-junit-export Results\junitReport.xml 

Upvotes: 0

Related Questions