CircleCI is a well-known CI/CD tool available on-premises and as SaaS.
Xray does not provide yet a plugin for CircleCI. However, it is easy to setup CircleCI in order to integrate it with Xray.
Since Xray provides a full REST API, you may interact with Xray, for submitting results for example.
In this scenario, we want to get visibility of the automated test results from some tests implemented in Java, using the JUnit framework.
This recipe could also be applied for other frameworks such as NUnit, TestNG or Robot.
We need to setup a project based on a Git repository containing the code along with the configuration for CircleCI build process.
The tests are implemented in a JUnit class as follows.
The CircleCI configuration file
.circleci/config.yml contains the definition of the build steps, including running the automated tests and submitting the results.
In order to submit those results, we'll just need to invoke the REST API (as detailed in Import Execution Results - REST).
However, we do not want to have the Xray credentials hardcoded in CircleCI's configuration file. Therefore, we'll use some environment variables defined in project settings, including:
- jira_user: for the Jira username
- jira_password: for the Jira user's password
- jira_server_url: for the Jira's base URL (e.g. http://yourjiraserver)
The user present in the configuration below must exist in the JIRA instance and have permission to Create Test and Test Execution Issues.
.circleci/config.yml a "step" must be included that will use "curl" in order to submit the results to the REST API.
curl -H "Content-Type: multipart/form-data" -u $jira_user:$jira_password -F "file=@target/surefire-reports/TEST-com.xpand.java.CalcTest.xml" "$jira_server_url/rest/raven/1.0/import/execution/junit?projectKey=CALC"
We're using "curl" utility that comes in Unix based OS'es but you can easily use another tool to make the HTTP request; however, "curl" is provided in the container used by CircleCI.