I am using Robotframework_xray to populate results from Azure DevOps pipeline to X-Ray/Jira but getting Error.
Below is the Yaml I am using.
Pipeline Definition
trigger:
- main
resources:
webhooks:
- webhook: “MyWebhookTrigger”
connection: “MyWebhookConnection”
pool:
vmImage: ubuntu-latest
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: ‘3.11’
displayName: ‘Use Python $(python.version)’
continueOnError: true - script: python -m site --user-site
- script: |
python -m pip install --upgrade pip
python -m pip install robotframework-xray --no-cache-dir --user
export PATH=$HOME/.local/bin:$PATH
export PYTHONPATH=$HOME/.local/lib/python3.11/site-packages:$PYTHONPATH
echo “Updated PATH: $PATH”
echo “Updated PYTHONPATH: $PYTHONPATH”
python -m pip show robotframework-xray || echo “robotframework-xray NOT FOUND”
displayName: ‘Install dependencies’
continueOnError: true - script: |
echo “Listing files in $(Build.SourcesDirectory)”
ls -R $(Build.SourcesDirectory)
displayName: ‘List Files in Source Directory’
continueOnError: true - script: |
cd /home/vsts/.local/lib/python3.11/site-packages #This is the path that package installed
ls /home/vsts/.local/lib/python3.11/site-packages
displayName: ‘list files under /home/vsts/.local/lib/python3.11/site-packages’ - script: |
/home/vsts/.local/lib/python3.11/site-packages #Add test inside it or it report Suite ‘Site-Packages’ contains no tests or tasks.
echo -e “*** Test Cases ***\nExample Test Case\n [Documentation] This is a simple test case\n [Tags] smoke\n Log Hello, Robot Framework!” > test.robot
displayName: ‘add test.robot to /home/vsts/.local/lib/python3.11/site-packages’ - script: |
robot .
displayName: ‘Robot Test Execution’
continueOnError: true - script: |
echo “Python Version:”
python --version
echo “Pip Version:”
python -m pip --version
echo “Pip Installation Path:”
which pip
echo “Python Executable Path:”
which python
displayName: ‘Check Python Version and Environment’
continueOnError: true - script: |
echo “Checking Python Module Search Path:”
python -c “import sys; print(sys.path)”
echo “Checking if robotframework_xray module is available:”
python -c “import robotframework_xray”
displayName: ‘Verify Python Module and Path’
continueOnError: true - script: |
python -m pip freeze
displayName: ‘List installed Python packages’
continueOnError: true - script: |
export PYTHONPATH=$HOME/.local/lib/python3.11/site-packages:$PYTHONPATH
python -m robotframework_xray --robotxml results/output.xml --xrayjson results/xray_results.json
displayName: ‘Convert Robot Results to Xray Format’
continueOnError: true - script: |
python -c “import sys; print(sys.path)”
python -m robotframework_xray --robotxml results/output.xml --xrayjson results/xray_results.json
displayName: ‘Debug - Confirm Module Path and Convert Robot Results to Xray Format’
continueOnError: true - script: |
python -c “import sys; print(sys.path)”
displayName: ‘Check Python Module Search Path’ - script: |
TOKEN=$(curl -s -X POST https://xray.cloud.getxray.app/api/v2/authenticate
-H “Content-Type: application/json”
-d ‘{“client_id”: “$(XRAY_CLIENT_ID)”, “client_secret”: “$(XRAY_CLIENT_SECRET)”}’ | tr -d ‘"’)
RESPONSE=$(curl -s -X POST “://xray.cloud.getxray.app/api/v2/import/execution/robot”
-H “Authorization: Bearer $TOKEN”
-H “Content-Type: application/json”
–data @results/xray_results.json)
TEST_EXECUTION_ID=$(echo $RESPONSE | jq -r ‘.key’)
echo “##vso[task.setvariable variable=TEST_EXECUTION_ID]$TEST_EXECUTION_ID”
displayName: ‘Upload Robot Results to Xray & Capture Execution ID’
continueOnError: true
- script: |
echo “Captured Test Execution ID: $(TEST_EXECUTION_ID)”
displayName: ‘Debug - Print Test Execution ID’
continueOnError: true - script: |
curl -X POST “//xray.cloud.getxray.app/api/v2/testplan/addtestexecutions”
-H “Authorization: Bearer $TOKEN”
-H “Content-Type: application/json”
–data “{“testExecutionKey”: “$(TEST_EXECUTION_ID)”, “testPlanKey”: “PLAN-456”}”
displayName: ‘Link Execution to Xray Test Plan’
continueOnError: true - script: |
echo “Final step to clean up or log final messages”
displayName: ‘Final Cleanup Step’
condition: always()