Giter Club home page Giter Club logo

xray-maven-plugin's Introduction

Xray Maven Plugin

build workflow license Gitter chat Maven Central Version Quality Gate Status

This is an open-source maven plugin for interacting with Xray (server/datacenter and cloud), used in CI/CD for assisting in test automation flows, such as reporting test results back to Xray and, by consequence, Jira.

This plugin is a totally new implementation, made from scratch, and should not be mistaken with the proprietary maven plugin originaly provided by Xray. It makes use of the public APIs provided by Xray (see references at bottom of this page), which we recommend for you to have a look as these may have some constraints that also apply to this plugin.

The Xray Maven Plugin is maintained by and in the open-source spirit.

The general flow for importing test automation results is as simple as submiting them back to Xray. For Gherkin-based frameworls (e.g., Cucumber, Behave, SpecFlow), the flow is slightly different and require additional steps (more on these flows here).

This plugin provides these tasks:

  • xray:import-results
  • xray:import-features
  • xray:export-features

More info about these ahead.

How to use

This plugin is available on (Maven) Central Repository, which is configured by default in your Maven instalation.

Add the following dependency to your pom.xml, where the <configuration> is optional and should be adapted to your use case.

        <plugin>
            <groupId>app.getxray</groupId>
            <artifactId>xray-maven-plugin</artifactId>
            <version>0.8.0</version>
            <scope>test</scope>
            <configuration>
                <clientId>215FFD69FE46447280000000000</clientId>
                <clientSecret>1c00f8f22f56a8684d7c18cd61470000000</clientSecret>
                <cloud>true</cloud>
                <projectKey>CALC</projectKey>
                <fixVersion>1.0</fixVersion>
                <reportFormat>junit</reportFormat>
                <reportFile>target/junit.xml</reportFile>
            </configuration>
        </plugin>

Configuration parameters (e.g., "reportFormat") can also be specified from the command line using -D (e.g., "-Dxray.reportFormat=junit"). In this case, the parameters have the xray. prefix.

There are a set of common configurations related to the Xray details and its authentication. Besides, each task has its own configuration parameters as shown ahead.

This repository provides a bunch of usage examples, both for Xray cloud and Xray server/datacenter.

Common configurations

For Xray server/datacenter users (i.e., using Xray on Jira server/datacenter):

parameter command line parameter description example
cloud xray.cloud set to false if not using Xray cloud (default: false) false
jiraBaseUrl xray.jiraBaseUrl Jira server/DC base URL http://10.0.0.1
jiraUsername xray.jiraUsername username of Jira user to use on API calls someuser
jiraPassword xray.jiraPassword password of Jira user to use on API calls somepass
jiraToken xray.jiraToken Jira PAT (Personal Access Token) used instead of username/password
ignoreSslErrors xray.ignoreSslErrors ignore SSL errors, e.g., expired certificate (default: false)
timeout xray.timeout connection timeout in seconds (default: 50)
verbose xray.verbose set to true to enable verbose mode (default: false); information will be visible if running mvn with debug output by using -X or --debug true

For Xray cloud users (i.e., using Xray on Jira cloud):

parameter command line parameter description example
cloud xray.cloud set to true if using Xray cloud (default: false) true
clientId xray.clientId client id of the API key configured on Xray Cloud xxxx...
clientSecret xray.clientSecret client id of the API key configured on Xray Cloud xxxx...
cloudApiBaseUrl xray.cloudApiBaseUrl Xray Cloud REST API base URL (default: https://xray.cloud.getxray.app/api/v2); useful for deployments having data residency. Check possible values in the docs https://eu.xray.cloud.getxray.app/api/v2
timeout xray.timeout connection timeout in seconds (default: 50) 50
verbose xray.verbose set to true to enable verbose mode (default: false); information will be visible if running mvn with debug output by using -X or --debug true

In order to obtain the API key (client id + client secret pair) please ask you Jira admin (see reference at bottom). There are also task specific configurations. More info ahead, on the respective task section.

Tasks

Importing test automation results

In order to import test results, we need to use the xray:import-results task.

 mvn clean compile test xray:import-results

Note that in the previous example the test task may fail aborting maven and thus not importing the test results to Xray. To overcome this, we can pass an argument to instruct Surefire to ignore the test failures; this can also be done at pom.xml level.

 mvn clean compile test xray:import-results -Dmaven.test.failure.ignore=true 

The pom.xml needs to be configured properly (see available configurations). As an alternative to hardcode the configurations, it's also possible to pass them right from the command line as mentioned earlier, or even have some on the pom.xml and another specificed through command line parameters.

 mvn clean compile test xray:import-results -Dxray.reportFormat=junit -Dxray.reportFile=results/junit.xml

Configurations for importing test results

There are two ways of importing results. The first one is more simple and also known as "standard" (due to how it is called in terms of REST API) where we provide all or a mix of predefined and common parameters (projectKey, version, revision, testPlanKey, testExecKey, testEnvironment) that are enough for most usage scenarios. There is another way importing results though, that allow us to customize any field on the Test Execution issue or even on the Test issues that may be created; in this case, we need to pass the testExecInfoJson and/or the testInfoJson fields. This approach, also known has "multipart" due to the endpoint it uses, even though more flexible will require us to specify common fields such as the project key, version, and other, within the respective JSON field.

In sum, if we decide to use the first approach we can use these parameters: projectKey, version, revision, testPlanKey, testExecKey, testEnvironment. If we decide to use the second approach to either customize the target Test Execution or Test issues, then we can only use the testInfoJson and testExecInfoJson parameters. **For this reason, it's not possible to use the parameters projectKey, version, revision, testPlanKey, testExecKey, testEnvironment together with testInfoJson and testExecInfoJson at the same time.

setting command line parameter description mandatory/optional example
reportFormat xray.reportFormat format of the report (junit, testng, nunit, xunit, robot, xunit, cucumber, behave) mandatory junit
reportFile xray.reportFile file with the test results (relative or absolute path); it can also be a directory (all .xml files will be imported in this case); finally, it can also be a regex that applies to the current working directory mandatory target/junit.xml
projectKey xray.projectKey key of Jira project where to import the results mandatory (doesn't apply to "cucumber" or "behave" report formats, for legacy reasons) CALC
testExecKey xray.testExecKey issue key of Test Execution, in case we want to update the results on it optional CALC-2
testPlanKey xray.testPlanKey issue key of Test Plan to link the results to optional CALC-1
version xray.version version of the SUT, that corresponds to the Jira project version/release; it will be assigned to the Test Execution issue using the "fixVersion(s)" field optional 1.0
revision xray.revision source code revision or a build identifier optional 123
testEnvironment xray.testEnvironment usually, a test environment name/identifier (e.g., browser vendor, OS versio , mobile device, testing stage); multiple test environments may be specified though using ";" as delimiter optional chrome
testInfoJson xray.testInfoJson path to a JSON file containing attributes to apply on the Test issues that may be created, following Jira issue update syntax optional -
testExecInfoJson xray.testExecInfoJson path to a JSON file containing attributes to apply on the Test Execution issue that may be created, following Jira issue update syntax optional -
abortOnError abort, if multiple results are being imported, and exit with error if uploading results fails optional -

Xray server/DC and Xray cloud support mostly the same formats, but not exactly for legacy reasons. Besides, not all formats support the same parameters; please check the respective product documentation. The following table sums this info.

reportFormat supported Xray variant notes
xray cloud and server/DC
junit cloud and server/DC
xunit cloud and server/DC
nunit cloud and server/DC
robot cloud and server/DC
testng cloud and server/DC
cucumber cloud and server/DC in this specific case, it's not possible to use the parameters projectKey, version, revision, testPlanKey, testExecKey, testEnvironment (due to the way the underlying "standard" endpoint for Cucumber works)
behave cloud and server/DC in this specific case, it's not possible to use the parameters projectKey, version, revision, testPlanKey, testExecKey, testEnvironment (due to the way the underlying "standard" endpoint for Cucumber works)

Technical info of how it works (internal)

This task makes use of different REST APIs for importing test automation results (see reference at the bottom). Related to each report format (e.g., junit, testng, etc) there are usually 2 endpoints for submiting test results: the so called "standard" and the "multipart" one. Whenever importing results, for a given report format, the plugin will use one of these endpoints based on whether testInfoJson or testExecInfoJson are provided; if none of them are provided, the "standard" endpoint, otherwise the "multipart" endpoint will be used.

Importing Cucumber results and associating to Test Plan/Test Environment/other

As detailed before, and not like happens with other formats, whenever importing cucumber/behave results it's not possible to use the parameters projectKey, version, revision, testPlanKey, testExecKey, testEnvironment parameters. This is due to the way the Cucumber endpoints work (as of July 2024). The "standard" Cucumber/Behave REST API endpoints dont' support these parameters; as this plugin is mostly an wrapper around the available REST API endpoints, it also inherits their limitations. However, Xray provides slightly different endpoints, also known as the "multipart" endpoints; these endpoints are more flexible and allow you to customize the fields you wish on the target Test Execution that will be created (yes, using these endpoints will always lead to the creation of new Test Executions).

To make this maven plugin use the underlying multipart endpoint and therefore be able to customize the target Test Execution, we just have to define the testExecInfoJson parameter with a filename containing the customization JSON. We'll show 2 examples: one for Xray Cloud and an equivalent for Xray Datacenter (the syntax is slightly different). So, don't specify any of the parameters projectKey, version, revision, testPlanKey, testExecKey, testEnvironment as they will be simply ignored.

Example follows ahead of testExecInfoJson content for Xray Cloud. In this case we're going to create the Test Execution with the results on the Jira project having the key CALC, on the version v3.0, and associate it with the Test Plan having key CALC-15. The Test Execution will also be associated with the Test Environment named chrome.

{
    "fields": {
        "project": {
            "key": "CALC"
        },
        "summary": "Brand new Test execution",
        "issuetype": {
            "name": "Test Execution"
        },
        "fixVersions" : 
                [
                 {
                        "name": "v3.0"
                 }
                ]

    },
    "xrayFields": {
        "testPlanKey": "CALC-15",
        "environments": ["chrome"]
    }
}

Example follows of testExecInfo content for Xray Datacenter. In this case we're going to create the Test Execution with the results on the Jira project having the key CALC, on the version v3.0, and associate it with the Test Plan having key CALC-15. The Test Execution will also be associated with the Test Environment named chrome. Note that the syntax is different from the one for Xray Cloud; in this case, to be able to set the Test Plan or the Test Environment(s), you'll need to find out the corresponding custom field ids; to do that, check with your Jira administrator (info can be obtained from Issues > Custom fields). Also, a more simple way would be to invoke the REST API to figure it out (e.g., https://yourjiraserver/rest/api/2/field as mentioned here).. and that info is visible on the response. Anwyway, the following example assumes Test Plan custom field has an id "11807" and the Test Environments has an id "11805"; adjust it for your case.

{
    "fields": {
        "project": {
            "key": "CALC"
        },
        "summary": "Brand new Test execution",
        "issuetype": {
            "name": "Test Execution"
        },
        "customfield_11805" : [
            "chrome"
        ],
        "customfield_11807" : [
            "CALC-15"
        ],
        "fixVersions" : 
                [
                 {
                        "name": "v3.0"
                 }
                ]
    }
}

For more information, please read the following Cucumber related documentation (or the corresponding one for Behave):

Importing/synchronizing Cucumber .feature files to Xray

One of the possible workflows for using Gherkin-based frameworks is to use git (or other versioning control system) as the master to store the corresponding .feature files (more info here). In order to provide visibility of test results for these tests (i.e. gherkin Scenarios), these need to exist in Xray beforehand. Therefore, we need to import/synchronize them to Xray. Note that there is no direct integration; the integration is adhoc, i.e., the following task is run on a local copy of the respository where the .features are stored in.

 mvn clean compile test xray:import-features -Dxray.inputFeatures=features/

Note: how Xray relates the Scenarios/Background to the corresponding Test or Precondition issues is described in Xray technical documentation (e.g., Xray cloud docs).

Configurations for importing/synchronizing Cucumber .feature files to Xray

parameter command line parameter description mandatory/optional example
projectKey xray.projectKey key of Jira project where to import the Cucumber Scenarios/Backgrounds as Test and Precondition issues mandatory (if projectId not used) CALC
projectId xray.projectId Xray cloud only: id of Jira project where to import the Cucumber Scenarios/Backgrounds as Test and Precondition issues mandatory (if projectKey not used) 1000
source xray.source ?? optional ??
testInfoJson xray.testInfoJson path to a JSON file containing attributes to apply on the Test issues that may be created, following Jira issue update syntax optional -
precondInfoJson xray.precondInfoJson path to a JSON file containing attributes to apply on the Precondition issues that may be created, following Jira issue update syntax optional -
inputFeatures xray.inputFeatures either a .feature file, a directory containing .feature files, or a zipped file containing .feature files mandatory features/
updateRepository xray.updateRepository create folder structure in Test Repository based on the folder structure in the .zip file containing the .feature files; default is false. Only supported on Xray server/DC. optional true

Technical info of how it works (internal)

This task makes use of a specific REST API avaiable for importing .feature files (for legacy reasons, also known as "importing Cucumber tests"). The .feature files are zipped and sent in one REST API call made to Xray. Link to the REST API endpoint details at the bottom (both for server/datacenter and cloud).

Exporting/generating Cucumber .feature files from Xray

No matter which worflow you decide to use for dealing with Gherkin-based tests (e.g., Cucumber .feature files and corresponding Scenarios), as part of that workflow comes the need to extract/generate the .feature files based on Scenarios or Backgrounds detailed in Xray using Test or Precondition issues. This plugin provides a task for this purpose. It will download/generate .feature files to a local folder from existing information in Xray. The Feature, Scenario elements will be properly tagged with info from Xray.

 mvn xray:export-features -Dxray.issueKeys=CALC-1,CALC-2 -Dxray.outputDir=features/

Files on the destination folder will be overwritten; however, if this directory contains other information (including other .feature files) you may need to remove them before generating the .feature files into this directory.

Note: how Xray generates the .feature files with the Scenarios/Background from existing Test or Precondition issues is described in Xray technical documentation (e.g., Xray cloud docs).

Configurations for exporting/generating Cucumber .feature files from Xray

parameter command line parameter description mandatory/optional example
issueKeys xray.issueKeys issue keys of direct or indirect references to Cucumber/Gherkin tests/scenarios (e.g., Test issue keys), delimited by comma mandatory (or optional if filterId is used instead) CALC-1,CALC-2
filterId xray.filterId id of the Jira filter containing direct or indirect references to Cucumber/Gherkin tests/scenarios mandatory (or optional if issueKeys is used instead) 12000
outputDir xray.outputDir output directory where the .feature files should be extracted to mandatory features/

Technical info of how it works (internal)

This task makes use of a specific REST API avaiable for exporting/generating .feature files (for legacy reasons, also known as "exporting Cucumber tests"). Link to the REST API endpoint details at the bottom (both for Xray on Jira server/datacenter and cloud).

FAQ

  1. Is this the same maven plugin as the original one made by Xray team?

No. This is a totally new one, made from scratch and open-source.

  1. If we have questions/support issues, where should those be addressed?

It's an open-source project, so it should be handled in this GitHub project and supported by the community. If you want to use the previous, proprietary plugin, you can do so and that has commercial support, if you have a valid license.

  1. Are the underlying APIs the same for Xray server/datacenter and Xray Cloud? Are the available options the same? Are the supported test automation report formats the same?

Not exactly. Xray server/datacenter and Xray cloud, even though similar, are actually distinct products; besides Jira server/datacenter and Jira cloud are different between themselves and have different capabilities. This plugin makes use of the available REST APIs for Xray server/datancer and Xray cloud, so you should check them to see exactly what is supported for your environment.

Contact

You may find me on Twitter. Any questions related with this code, please raise issues in this GitHub project. Feel free to contribute and submit PR's. For Xray specific questions, please contact Xray's support team.

Disclaimer

This project is in early stage; the setting names and other are subject to change.

Acknowledgments

  • Thanks to Eugen, and other authors, along with the many tutorials provided at baeldung.com.
  • Thanks to Hugo Braz for all the valuable feedback and previous work done in the scope of the previous, proprietary Maven plugin for Xray.

TO DOs

  • review pom.xml and make it cleaner (help neeeded and appreciated!)
  • add code coverage information with jacoco, as I couldnt get it working (help needed and appreciated!)
  • add unit tests
  • option to remove temporary .zip file created whenever importing Gherkin/cucumber .feature files
  • ability to attach files/evidence to test runs (needs some thought)

References

LICENSE

BSD 3-Clause

xray-maven-plugin's People

Contributors

bitcoder avatar dependabot[bot] avatar dgautier avatar mk868 avatar

Stargazers

Inna Zanko avatar DJCrabhat avatar Ishan avatar João Matos avatar Orçun Balcılar avatar  avatar Abu bakar  avatar  avatar Omar RACHED avatar Addison Snyder avatar Jefferson Martines avatar Jarrian Gojar avatar Naye avatar Fayz Sabir avatar  avatar Nishith Shah avatar robin gupta avatar  avatar  avatar André Pires avatar  avatar Charly avatar Amol Deokar avatar  avatar  avatar mni avatar

Watchers

Rui Rodrigues avatar Xavier Fernandes avatar Joe Walsh avatar  avatar João Matos avatar

xray-maven-plugin's Issues

Error on mvn import-feature for ServerDC

Hello,

I'm facing an error when new scenarios are send to jira.
Note:

  • This error doesn't happen to update the existing scenarios
  • This error doesn't happen for only one new scenario

When I call mvn mvn xray:import-features -D"xray.inputFeatures"=my.feature -X I am receiving this error:

java.io.IOException: Unexpected HTTP code Response{protocol=http/1.1, code=500, message=, url=https://jira.sp.vodafone.com/rest/raven/2.0/import/feature?projectKey=IT&updateRepository=false}
        at app.getxray.xray.XrayFeaturesImporter.importServerDC(XrayFeaturesImporter.java:340)
        at app.getxray.xray.XrayFeaturesImporter.importFrom(XrayFeaturesImporter.java:241)
        at app.getxray.maven.plugin.xray.ImportFeaturesMojo.execute(ImportFeaturesMojo.java:171)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
        at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2(MojoExecutor.java:370)
        at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:351)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:215)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:171)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:163)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)

This is part of debug:

[DEBUG] REQUEST_URL: https://company.com/rest/raven/2.0/import/feature?projectKey=IT&updateRepository=false
[DEBUG] REQUEST_METHOD: POST
[DEBUG] REQUEST_CONTENT_TYPE: multipart/form-data; boundary=61e3637e-6d33-459f-ad53-5bab17c09880
[DEBUG] RESPONSE_CONTENT_TYPE:application/json;charset=UTF-8
[DEBUG] RESPONSE_HTTP_STATUS: 500
[DEBUG] RESPONSE_BODY:
[DEBUG] =======================
[DEBUG] java.util.NoSuchElementException: No value present
        at java.util.Optional.get(Optional.java:135)
        at com.xpandit.raven.testimport.service.impl.TestImportServiceImpl.b(Unknown Source)
        at com.xpandit.raven.testimport.service.impl.TestImportServiceImpl.a(Unknown Source)
        at com.xpandit.raven.testimport.service.impl.TestImportServiceImpl.a(Unknown Source)
        at com.xpandit.raven.testimport.service.impl.TestImportServiceImpl.b(Unknown Source)
        at com.xpandit.raven.testimport.service.impl.TestImportServiceImpl.a(Unknown Source)
        at com.xpandit.raven.testimport.service.impl.TestImportServiceImpl.a(Unknown Source)
        at com.xpandit.raven.rest.api.v1.test.a.b.a(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor13969.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.atlassian.plugins.rest.common.interceptor.impl.DispatchProviderHelper$ResponseOutInvoker.lambda$_dispatch$0(DispatchProviderHelper.java:181)

Thanks

xray:import-features failes including Java DocString

I'd like the plugin to transfer a Java DocString into the jira ticket

My feature is like

Scenario: A Step with JSON
  Given a JSON
    """
    {
      "any": "thing"
    }
    """
When I call mvn xray:import-features 
Then I want Jira to have the JSON included

The created Jira Issue does not contain the content of the DocString

Multiple Issues observed when uploading the cucumber results

In our testing framework, we generate multiple junit test runner classes for cucumber feature files at run time and hence multiple json report files. Then Observed the below issues when trying to upload the multiple cucumber report files using this plugin:

  1. Does not accept directory with list of json files ex: target/reports
  2. regex does not accept ex: target/reports/*.json
  3. socket timeout exception at times because of long response time from Xray Cloud API calls

Associate TestExec to Test Plan

Hello ,
I want to associate the testExec to testPlan after an execution of automation tests .
It works with a reportFormat (Junit , Testng) but not works with a reportFormat (Cucumber) .
PS: with the format Junit and testNg the information in not clean , can't import all of steps of scenario Outline.
This my configuration 👍
Capture d’écran 2024-07-08 à 14 07 12

Split JUnit XML results into multiple files

The publishing step often fails on large test suites due to file size limitations. Standard Surefire reports are typically split by test class. It would be nice to have the option to do the same with XRay results to avoid file size limitations when publishing reports via the XRay APIs.

Import Scenario comment to Jira description field

Given a test issue in Jira Xray
And the issue has description = "text in description"
When I export the test to cucumber via the UI
Then I get a comment "text in description" above the tags of the feature

Example of export:

#language: de
Funktionalität: Default

	#text in description
	@TEST_UVIX-338
	Szenario: example test
		Angenommen any steps

Given a feature in the mentioned format with a comment above the tags of the feature
when I use the mvn xray:import-features command
then the comment is written to the description in jira issue

400 http error using multipart behavior

When i tried to use a separate file to customize the test execution i always get 400 http error, we are using xray cloud, if i do the same using postman multipart works, i also tried adding some other keys like jiraBaseUrl, jiraToken but i always have the same response

pom.xml

<plugin>
   <groupId>app.getxray</groupId>
   <artifactId>xray-maven-plugin</artifactId>
   <version>0.7.0</version>
   <configuration>
      <scope>test</scope>
      <clientId>***</clientId>
      <clientSecret>***</clientSecret>
      <cloud>true</cloud>
      <reportFormat>cucumber</reportFormat>
      <testExecInfoJson>src/main/resources/xrayInfo.json</testExecInfoJson>
      <reportFile>${project.build.directory}/cucumber-reports/cucumber-report.json</reportFile>
      <abortOnError>true</abortOnError>
   </configuration>
</plugin>

error

java.io.IOException: Unexpected HTTP code Response{protocol=http/1.1, code=400, message=Bad Request, url=https://xray.cloud.getxray.app/api/v2/import/execution/cucumber/multipart}
	at app.getxray.xray.XrayResultsImporter.submitMultipartCloud(XrayResultsImporter.java:427)
	at app.getxray.maven.plugin.xray.ImportResultsMojo.execute(ImportResultsMojo.java:215)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
	at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:301)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:211)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:165)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:157)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:121)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:127)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:294)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:960)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:293)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:196)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:577)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
[ERROR] Unexpected HTTP code Response{protocol=http/1.1, code=400, message=Bad Request, url=https://xray.cloud.getxray.app/api/v2/import/execution/cucumber/multipart}
java.io.IOException: Unexpected HTTP code Response{protocol=http/1.1, code=400, message=Bad Request, url=https://xray.cloud.getxray.app/api/v2/import/execution/cucumber/multipart}
	at app.getxray.xray.XrayResultsImporter.submitMultipartCloud(XrayResultsImporter.java:427)
	at app.getxray.maven.plugin.xray.ImportResultsMojo.execute(ImportResultsMojo.java:215)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
	at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:301)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:211)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:165)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:157)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:121)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:127)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:294)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:960)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:293)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:196)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:577)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)

xrayInfo.json

{
  "fields": {
    "summary": "Test execution, 2023/01/26 09:33:50",
    "issuetype": {
      "id": "issue_type_id"
    },
    "project": {
      "id": "project_id"
    },
    "description": "Automated test execution, Platform: android, Date: 2023/01/26 09:33:50",
    "assignee": {
      "id": "assigned_id"
    }
  }
}

command to execute tests

 mvn clean test -Dcucumber.filter.tags="@login" xray:import-results

i hope you can take a look.
Thanks

Option to use JIRA issue name instead of issue key for output file names

Hello,

I am currently using the mvn xray:export-features command to export features and scenarios from JIRA using the Xray plugin. The output file names are in the format 1_XRAY-3115.feature where XRAY-3115 is the issue key.

However, I want to replace the issue key in the file name with the corresponding JIRA issue name. In other words, instead of 1_XRAY-3115.feature, I want the file name to represent the actual JIRA issue name. This would provide a more meaningful context when looking at the output files.

Could you consider adding a feature that allows the customization of the output file names in this way?

Thank you for considering my request.

ability to attach files whenever uploading results, in the Test Execution issue

Provide the ability to attach files whenever uploading results to Xray in Jira, in the Test Execution issue.
A given file can be identified or a regex (regex eventually may be limited to current working directory and subdirs).

Note: this will probably require new settings for Jira API credentials, namely on cloud.

Refs:

I can't get mvn xray:export-features -Dxray.filterId=10031 to work

Hello

I hope you can help me out.

I'm using the plugin to get my java cucumber test results from code/pipeline into XRay

import-features now works

now for export-features:
The command is:
mvn xray:export-features -Dxray.filterId=10031

Which results in 400 Bad request. With debugger I found out the error body (would be great if the plugin itself would show the error body on an error): {"error":"Error fetching filter information"}

The Jira filterId filters for the test set that contains the test cases that need to be exported after the import. I would expect this to work since it is an indirect reference to the test cases I need to export. Documentation states: "id of the Jira filter containing direct or indirect references to Cucumber/Gherkin tests/scenarios". This filter is created on the same user that is used for the API requests

So something is wrong with the filter, somehow. What should I do differently?

configuration in the pom.xml:

  <plugin>
    <groupId>app.getxray</groupId>
    <artifactId>xray-maven-plugin</artifactId>
    <version>0.6.0</version>
    <configuration>
      <abortOnError>true</abortOnError>
      <inputFeatures>src/test/resources/nl/etpa/idcons/features</inputFeatures>
      <outputDir>src/test/resources/nl/etpa/idcons/features</outputDir>

      <clientId>xxx</clientId>
      <clientSecret>yyy</clientSecret>
      <projectKey>IDCONS</projectKey>
      <cloud>true</cloud>
      <reportFormat>cucumber</reportFormat>
      <reportFile>target/cucumber-reports/integration-test-report.json</reportFile>
    </configuration>
  </plugin>

Thanks for helping me out

I don't think the pom.xml snippet is correct on the readme

snippet from readme:

      <dependency>
            <groupId>app.getxray</groupId>
            <artifactId>xray-maven-plugin</artifactId>
            <version>0.7.0</version>
            <scope>test</scope>
            <configuration>
                <clientId>215FFD69FE46447280000000000</clientId>
                <clientSecret>1c00f8f22f56a8684d7c18cd61470000000</clientSecret>
                <cloud>true</cloud>
                <projectKey>CALC</projectKey>
                <fixVersion>1.0</fixVersion>
                <reportFormat>junit</reportFormat>
                <reportFile>target/junit.xml</reportFile>
            </configuration>
        </dependency>

I think it should be like:

<plugin>
            <groupId>app.getxray</groupId>
            <artifactId>xray-maven-plugin</artifactId>
            <version>0.7.0</version>
            <configuration>
                <clientId>215FFD69FE46447280000000000</clientId>
                <clientSecret>1c00f8f22f56a8684d7c18cd61470000000</clientSecret>
                <cloud>true</cloud>
                <projectKey>CALC</projectKey>
                <fixVersion>1.0</fixVersion>
                <reportFormat>junit</reportFormat>
                <reportFile>target/junit.xml</reportFile>
            </configuration>
</plugin>

issue with linking to Test Plan

Hello;

Version of plugin used: 0.6.0 (https://repo1.maven.org/maven2/app/getxray/xray-maven-plugin/0.6.0/)
Version of Jira used: v8.20.8
Version of mvn used : 3.6.0

Command maven:
mvn -gs my-global-settings.xml xray:import-results -Dmaven.repo.local=/mytmp/maven-repositories -Dxray.jiraToken=**** -Dxray.jiraBaseUrl=https://myjira.server/ -Dxray.projectKey=ORI2 -Dxray.testPlanKey=ORI2-791 -Dxray.cloud=false -Dxray.reportFormat=junit -Dxray.reportFile=/mytmp/myresults.xml

The test executions tickets are created correctly in Jira
However, the links to the test plan ORI2-791 are not created.

Have you already encountered that kind of issue or did I forget something ?

Thanks

Github releases not up to date with 0.6.0

Version 0.6.0 has been released in the official Nexus repository.
and your text refers to it.
The Github releases still does not show 0.6.0. It would be nice to update that.

Import does not work with Cucumber failed scenario

Hi!

I have been using the plugin with Cucumber framework.

When I execute a test from the command line and the commands is in one line (e.g. mvn clean test xray:import-results) and there are failed scenarios, then the import does not work.
If there are not any failed scenarios it works.

Of course,the commands are working after each other.

Configuration:

        <plugin>
            <groupId>app.getxray</groupId>
            <artifactId>xray-maven-plugin</artifactId>
            <version>0.7.0</version>
            <configuration>
                <cloud>false</cloud>
                <jiraBaseUrl>**********</jiraBaseUrl>
                <jiraUsername>********</jiraUsername>
                <jiraPassword>********</jiraPassword>
                <reportFormat>cucumber</reportFormat>
                <reportFile>target/CucumberResult.json</reportFile>
                <abortOnError>true</abortOnError>
                <filterId>1200</filterId>
                <outputDir>features</outputDir>
            </configuration>
    </plugin>

Reproduction:

  1. Use a cucumber project where there will be some failed scenario
  2. Run test and import the results from CMD in one line: mvn clean test xray:import-results
    The import does not work. I did not get any response message from Xray. As if the plugin do not send the json to Xray.

The import works in this case (the commands in two line):

  1. Use a cucumber project where there will be some failed scenario
  2. Run test from CMD: mvn clean test
  3. Wait for end of tests
  4. Import: mvn xray:import-results

Thanks for your help.

Support for special naming when exporting feature files

When I have exported feature files, they have been named in a format consisting of numeric value and jira issue id. But could we support to name the file as a given one by the user?
Actual -> 1. feature
Desired -> Cucumber.feature

The maven goals import-features and import-results are not working anymore for my project

I am writing today because I am using you xray-maven-plugin for Maven projects. It was working perfectly fine for the last months, but recently I noticed it is not working as expected. The maven goals "mvn xray:import-features -Dxray.inputFeatures=/path" and "mvn xray:import-results -Dxray.reportFile=/path" is not working anymore. I receive constanly 400 error message, Bad request. As I as a user don't directly create the request with the maven goal, I think that something went broken in the configurations. Could it possible to investigate the problem and let me know if it is a problem on your side or not? It would be very kind to fix this issue.

verbose mode

add a verbose mode that:

  • logs the called URL
  • logs the HTTP content-type of the request
  • logs the HTTP method of the request
  • logs the HTTP status code from the response
  • logs the HTTP content-type of the request
  • logs the HTTP body from the response

Adding support for region based XRay APIs

This is a very helpful plugin. Based on current implementation I want to know how can we extend this plugin for region based XRAY APIs.

e.g. default API URL is https://xray.cloud.getxray.app/
But if I need to access region based XRAY API like https://en.xray.cloud.getxray.app/api/v2/

How can we do it through this plugin.

Please share your insights on this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.