Search code examples
jenkinsjenkins-pipelinecypresscypress-cucumber-preprocessorjira-xray

Xray importToSameExecution not working for Cypress Cucumber JSON in Jenkins Pipeline


I'm trying to import Cypress Cucumber JSON results into same Xray execution using "Xray - Test Management for Jira Plugin" in Jenkins pipeline. But in each run Xray is creating a new execution.

Jenkins Pipeline

stage('Upload xray test results') {
    step([$class: 'XrayImportBuilder', endpointName: '/cucumber', projectKey: 'SPT', testPlanKey: '3081', testExecKey : 'SPT-3082', importToSameExecution: 'true', importFilePath: 'jsonlogs/log.json', importInParallel: 'false', serverInstance: '<<serverInstance>>'])
};

Xray Test Execution

enter image description here

Jenkins Console Log

enter image description here

Also I've added Execution ID as a tag in my feature file top level

enter image description here


Solution

  • For historical reasons, the related cucumber API endpoint is a bit different from other ones (i.e., for other report formats), in the sense that it doesn't allow you to specify the Test Execution issue key.. just the report file itself. Thus, those arguments on the pipeline syntax you shared are worthless.

    It's possible to update an existing Test Execution though. The cucumber JSON report needs to have the Test Execution issue key as a tag. To have it, add the Test Execution issue key as a tag before the "Feature: " section, right next to the tag where you have the reference to your "requirement". Let's say the existing Test Execution issue key is SPT-1000, then your feature needs to be something like:

    @SPT-1000 @REQ_SPT-3082
    Feature: xxx
    
    @TEST_SPT-2882
    Scenario: yyy
    
    

    Whenever you run this, the cucumber json will contain the reference to it.. and then whenever you import, Xray will know that it needs to update an existing Test Execution.

    Side note: if you use the cucumber multipart endpoint, it will always create a new Test Execution issue though.

    The provided link is for Xray server/DC, but even Xray cloud which has a different API, still uses the same logic.