Forum Discussion

slashsteiner's avatar
slashsteiner
New Contributor
3 months ago

Set Environment When Uploading Test Execution Result to Zephyr

We are using Zephyr Test Managment and Automation for Jira Cloud. We were able to setup a test execution via Gitlab CI and upload the result to Zephyr via https://api.zephyrscale.smartbear.com/v2/automations/executions/custom. But one thing that we can't figure out is to set the environment where we did the execution. We've tried passing "environment", "environmentId", "environmentName", etc. But none of them works. Zephyr doesn't seem to recognize them. We can't seem to find any documentation about it as well.

Here's what we tried so far:

{
    "version": 1,
    "executions": [
        {
            "source": "My Request",
            "result": "Failed",
            "testCase": {
                "name": "API response has status 200",
                "key": "TESTKEY-T123123",
                "environment": 3814706,
                "environmentId": 3814706,
                "environmentName": "QA"
            }
        }
    ]
}

And here's what we're always seeing in Zephyr:

 

Can anyone shed some light as to how we can make it work?

 

2 Replies

  • milekade8's avatar
    milekade8
    Occasional Visitor

    You can’t set the environment inside the testCase object. Instead, add "environmentId" directly in each execution item. That’s how Zephyr recognizes it. Keep other fields like testCase key and result separate.

    • slashsteiner's avatar
      slashsteiner
      New Contributor

      Hi milekade8​ , I've tried adding it as what you've suggested but still didn't work. Below were the combinations on what I've tried:

      Using environment id for "environment" and "environmentId"
      {
          "version": 1,
          "executions": [
              {
                  "source": "My Request",
                  "result": "Failed",
                  "environment": 3814706,
                  "environmentId": 3814706,
                  "testCase": {
                      "name": "API response has status 200",
                      "key": "TESTKEY-T123123"
                  }
              }
          ]
      }

      Using QA for "environment" and "environmentName"
      {
          "version": 1,
          "executions": [
              {
                  "source": "My Request",
                  "result": "Failed",
                  "environment": "QA",
                  "environmentName": "QA",
                  "testCase": {
                      "name": "API response has status 200",
                      "key": "TESTKEY-T123123"
                  }
              }
          ]
      }

      I was able to find a workaround and that is by sending each execution using the test execution endpoint (see this link) as it provides a parameter for the environment.