Search code examples
mavencucumberjira-xray

Xray-Maven plugin - testPlanKey / fixVersion / testEnvironment not populating in Jira


Using Serenity 4.0.1 to generate cucumber.json report, and the xray maven plugin to publish to Jira.

It is mostly working fine - Test Executions being created in Jira and results populated. Only problem is that they are not linking to the specified Test Plans, and the environment / fixVersion fields are not populating either.

Referring to this documentation: https://docs.getxray.app/display/XRAY/Integration+with+Maven#IntegrationwithMaven-Importingtestautomationresults

I have tried using both the command line parameters (as I am using to supply Jira credentials), as well as the plugin pom configuration setting (where I am supplying JiraBaseUrl amongst other things). So I know both methods are working, just not for these 3 fields it seems.

Here is the logged response I get from the plugin:

[INFO] response: {"testExecIssue":{"id":"16065764","key":"E2E-583","self":"https://jira.test.com/rest/api/2/issue/16065764"},"testIssues":{"success":[{"id":"16037818","key":"E2E-576","self":"https://jira.test.com/rest/api/2/issue/16037818","testVersionId":1433450}]},"infoMessages":[]}

Here is my plugin config:

    <plugin>
        <groupId>app.getxray</groupId>
        <artifactId>xray-maven-plugin</artifactId>
        <version>0.7.3</version>
        <configuration>
            <cloud>false</cloud>
            <jiraBaseUrl>https://jira.test.com</jiraBaseUrl>
            <projectKey>E2E</projectKey>
            <testEnvironment>UAT</testEnvironment>
            <fixVersion>1.0</fixVersion>
            <testPlanKey>E2E-577</testPlanKey>
            <reportFormat>cucumber</reportFormat>
            <reportFile>target/cucumber.json</reportFile>
        </configuration>
        <executions>
            <execution>
                <id>import-results</id>
                <phase>post-integration-test</phase>
                <goals>
                    <goal>import-results</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

And here is my maven command:

clean verify -e -X -Dcucumber.filter.tags="@E2E_Regression" -Dxray.testPlanKey="E2E-577" -Dxray.fixVersion=1.0 -Dxray.testPlanKey=E2E-577 -Dxray.testEnvironment=UAT -Dxray.jiraUsername=xxx -Dxray.jiraPassword=xxx

So wondering why these fields are not being populated at all?


Solution

  • The "cucumber" format uses internally the standard cucumber REST API endpoint, which doesn't support yet passing additional parameters as mentioned on the Xray Maven Plugin GitHub project page..

    GitHub documentation highlighting current constraints on cucumber handling

    The way to address this need would be to use the cucumber multipart endpoint instead; the documentation provides an example of an API request.

    curl -u admin:admin -F [email protected] -F [email protected] http://yourserver/rest/raven/1.0/import/execution/cucumber/multipart
    

    We can also achieve this using the xray-maven-plugin. To do that, you should remove the projectKey, testEnvironment, fixVersion, testPlanKey from both the pom.xml configuration and also the corresponding command line arguments. Why? Because they're not processed. Instead, you should specify the testExecInfoJson with a filename (e.g., testexec.json) and content similar to the following one:

    {
        "fields": {
            "project": {
                "key": "PROJECT_KEY"
            },
            "summary": "Test Execution for cucumber execution",
            "issuetype": {
                "name": "Test Execution"
            },
            "customfield_CF_TEST_ENVIRONMENT" : [
                "TEST_ENVIRONMENT_NAME"
            ],
        "customfield_CF_TEST_PLAN" : [ "TESTPLAN_KEY" ]
        },
            "fixVersions" : 
                    [
                     {
                            "name": "NAME_OF_RELEASE_IN_JIRA"
                     }
                    ]
    
    }
    

    You need to find the ids of the custom fields "Test Plan" and "Test Environment" in your Jira instance settings (or ask you Jira admin for them).

    An example of that content would be something like:

    {
        "fields": {
            "project": {
                "key": "CALC"
            },
            "summary": "Test Execution for cucumber Execution",
            "issuetype": {
                "name": "Test Execution"
            },
            "customfield_11805" : [
                "iOS"
            ],
            "fixVersions" : 
                    [
                     {
                            "name": "v3.0"
                     }
                    ]
    
            
        }
    }