Introduction
Integrating Xray into your DataOps.live pipeline allows you to push test results directly to Xray, enhancing your testing and reporting capabilities. This guide will walk you through the steps to add an Xray stage to your pipeline.
Prerequisites
- A DataOps.live account
- Access to your DataOps.live project
- Xray and Jira account credentials
- Basic knowledge of YAML and pipeline configuration
Step-by-Step Guide
1. Update the stages.yml
File
First, add a new stage for Xray in your stages.yml
file. This ensures that the Xray stage is recognized as part of the pipeline.
stages:
- Data Extraction
- Data Transformation
- Transformation Testing
- Generate Docs
- Xray
- Clean Up
2. Create the xray.yml
Configuration File
Create a new file named xray.yml
in the pipelines/includes/local_includes/
directory. This file will define the steps for the Xray stage.
.xray:
extends:
- .agent_tag
image: $DATAOPS_API_RUNNER_IMAGE
stage: Xray
icon: ${API_ICON}
variables:
JIRA_SERVER_URL: https://example.com
JIRA_USER: username
JIRA_PASSWORD: password
XRAY_PROJECT_KEY: EXAMPLE
script:
- 'curl -H "Content-Type: multipart/form-data" -u $JIRA_USER:$JIRA_PASSWORD -F "file=@report.xml" "$JIRA_SERVER_URL/rest/raven/1.0/import/execution/junit?projectKey=$XRAY_PROJECT_KEY"'
Xray Sources Upload:
extends:
- .xray
dependencies:
- Test all Sources
Xray Models Upload:
extends:
- .xray
dependencies:
- Test all Models
Explanation
.xray:
This is a reusable configuration block that can be extended by other jobs. It sets up the environment and steps for interacting with Xray.extends:
This line allows the .xray configuration to inherit properties from another predefined configuration (.agent_tag). This helps in maintaining consistency and reusability across your pipeline configurations.image:
Specifies the Docker image to be used for this stage. In this case, it uses the image defined by $DATAOPS_API_RUNNER_IMAGE, which should be set in your environment variables or pipeline configuration.stage:
Defines the stage in which this job runs. Here, it is set to Xray, aligning with the stage defined instages.yml
.icon:
Sets an icon for the stage, which can be useful for visual identification in your pipeline UI. This uses the ${API_ICON} variable.variables:
Defines environment variables required for the script to run. These include:JIRA_SERVER_URL:
The URL of your Jira server.JIRA_USER:
Your Jira username.JIRA_PASSWORD:
Your Jira password.XRAY_PROJECT_KEY:
The key of the Xray project where the results will be uploaded.script:
Contains the commands to be executed during this stage. The script uses curl to upload the test report (report.xml) to the Xray server.Xray Sources Upload: and Xray Models Upload:
These jobs extend the .xray configuration, inheriting all its properties.dependencies:
Specifies the jobs that must complete successfully before these jobs run. For Xray Sources Upload, it depends on Test all Sources, and for Xray Models Upload, it depends on Test all Models.
3. Include the Xray Configuration in full-ci.yml
Modify your full-ci.yml
file to include the new Xray configuration.
- /pipelines/includes/local_includes/xray.yml
4. Configure Test Stages to Archive the Generate Reports
Ensure that your test stages archive the reports to a known location. Update the test_all_models.yml
and test_all_sources.yml
files to include the paths attribute.
Test all Models:
script:
- run_tests
artifacts:
when: always
reports:
junit: $CI_PROJECT_DIR/report.xml
paths:
- $CI_PROJECT_DIR/report.xml
Test all Sources:
script:
- run_tests
artifacts:
when: always
reports:
junit: $CI_PROJECT_DIR/report.xml
paths:
- $CI_PROJECT_DIR/report.xml
Conclusion
By following these steps, you can successfully integrate Xray into your DataOps.live pipeline, allowing you to push test results directly to Xray. This integration enhances your testing workflow and provides better visibility into your test results.
For further assistance, refer to the DataOps.live and Xray documentation or contact support.