javajirajira-rest-apijira-zephyr

JIRA API: How to update test result using Version and Test Cycle?


Could someone share the steps and code that would allow me to update a test cycle for a given release? I can get it to update the test results for Ad Hoc, but that is not what I want. Here is what I have:

// 1. Get IssueId via "jira/rest/api/2/issue/" + issueKey
// 2. Get VersionId via "jira/rest/api/2/project/" + projectId + "/versions"
// 3. Get ProjectId via "jira/rest/api/2/project"
// 4. Create ExecutionId via "jira/rest/zapi/latest/execution", with issueId, projectId in header
// 5. Execute execution via "jira/rest/zapi/latest/execution" + executionId + "/execution" , with body containing status = 1 or 2

I have VersionId, but where do I put it? I need to get TestCycle Id, but I cannot figure out where to get it, and once I get it, where do i put it?


Solution

  • Test Cycles are organised by version and project in Zephyr for JIRA.So, you should make the below GET request to get cycle id's for a given version of the selected project.

    GET -  http://<jira_server>/rest/zapi/latest/cycle?projectId=10000&versionId=10100
    

    With the above request you will get the cycleId, use this id in Execution Resource API "http://jira_server/rest/zapi/latest/execution" as below to get Execution Id's present in that cycle.

    POST - http://<jira_server>/rest/zapi/latest/execution
    
    HEADERS
    Content-Type:application/json
    
    BODY
    {
      "issueId": 10600,
      "versionId": "10000",
      "cycleId": "16",
      "projectId": 10000
    }
    

    Now, use the executionId's as {id} in the below API to update the test result http:///rest/zapi/latest/execution/{id}/execute

    Usage

    PUT 
    http://<jira_server>/rest/zapi/latest/execution/{id}/execute
    
    HEADERS
    Content-Type:application/json
    
    BODY
    {
      "status": "1"
    }
    
    Response
    200
    

    If you still face any issues sign up to our support site "https://support.getzephyr.com/hc/en-us" using your company email id and use the option "Submit a Case" to raise a ticket with us and one of our support engineers would immediately contact you. It's a better channel to keep track of Zephyr issues.