cucumberjira-xrayx-ray

How to add file to the 'Evidance' using Cucumber JSON Multipart into the jenkinsci/xray-connector-plugin


I'd like to add file to the Evidence for new test execution.

enter image description here

How to upload file to the Evidance input using Cucumber JSON Multipart?

Xray plugin repo: jenkinsci/xray-connector-plugin

There is my multipart JSON:

{
  "fields": {
    "project": {
      "key": "${projectKey}"
    },
    "summary": "Test Execution for Cucumber results (Generated by job: ${BUILD_TAG})",
    "description": "Test Execution for Cucumber results (Generated by job: ${BUILD_TAG})",
    "issuetype": {
      "id": "12453"
    }
  },
  "xrayFields": {
    "testPlanKey": "${testPlanKey}",
    "environments": [
      "${env}"
    ]
  }
}

What should I add to this json to upload a file into Evidence input?


Solution

  • That Cucumber JSON multipart endpoint (similarly with other endpoints) doesn't provide a way to specify that field explicitly. The Xray JSON format (and either the standard or multipart endpoints) will allow you to specify that information; however, this format is not the most adequate one in case you want to upload Cucumber related results.

    You have two options, since in this case I guess we can exclude using Xray JSON format: a) use Cucumber JSON (either standard or multipart endpoint) and take advantage of the fact that Xray can process attachments (i.e. screenshots) that you can embed in the cucumber steps implementation (please see example on Xray docs where it briefly mentions it). You should look at cucumber's API to see how that can be done in terms of API. As we speak, in Java, I think you have to do +something like this in a hook

     scenario.attach(data, "image/png", "My screenshot"); 
    

    Example here.

    b) you can use your current approach and then use the GraphQL to update the evidence on the corresponding Test Run. This will be tricky to implement as you'll need to know the Test Execution issue key, then it's id and then use the proper GraphQL request to update evidence on a specific Test Run inside that Test Execution... this is not trivial though.