XML not generating for the playwright test running in Bitbucket pipeline
Asked by ragsagarm:

Currently, I am running my Playwright tests with a JavaScript framework in a Bitbucket pipeline for CI/CD. However, the issue is that my XML file is not being generated in the source directory within the root folder after committing the code to Bitbucket. The pipeline is picking up the `results.xml` file from the existing source directory instead of the newly generated file. Although the `results.xml` is stored as an artifact, the pipeline continues to use the outdated version from the root directory.  

this is my yml script for the pipeline   

<br />

image: mcr.microsoft.com/playwright:v1.42.1-jammy  
pipelines:  
default:  
- step:  
name: Build and Test  
caches:  
- node  
script:  
- npm ci  
- npx playwright test --reporter=html,junit  
- mv test-results/junit.xml results.xml  
artifacts:  
- playwright-report/\*\*  
- results.xml  
- jira-issues.json  
after-script:  
- \|  
echo "Checking for test results file..."  
if \[ -f "results.xml" \]; then  
echo "Test results file found."  
failed_tests=$(grep -c '\<failure' "results.xml")  
echo "Number of failed tests: $failed_tests"  
if \[ $failed_tests -gt 0 \]; then  
echo "Installing dependencies..."  
npm install request xml2js  
echo "Creating JIRA issues..."  
node create-jira-issues.js --results="results.xml" --node="create-jira-issues.js"  
else  
echo "No failed tests. Skipping JIRA issue creation."  
fi

echo "Installing Testmo CLI..."  
npm install -g @testmo/testmo-cli  
echo "Adding HTML artifact to Testmo..."  
testmo automation:resources:add-artifact \\  
--name "HTML Report" \\  
--file "playwright-report/index.html" \\  
--url "<https://bitbucket.org/ragms/demo/pipelines/results/$BITBUCKET_BUILD_NUMBER/steps/%7B993ed7d6-3bac-4985-84b6-b9e55c54ff5b%7D/artifacts>"  
echo "Updating Testmo with test results..."  
testmo automation:run:submit \\  
--instance=<https://cascadeintegration.testmo.net/> \\  
--project-id 1 \\  
--name "Build $BITBUCKET_BUILD_NUMBER" \\  
--source "test" \\  
--results="results.xml" \\  
--resources testmo-resources.json  
else  
echo "Test results file not found. Skipping JIRA issue creation and Testmo update."  
fi


Answers:
author: Patrik S
body: Hello [@ragsagarm](/t5/user/viewprofilepage/user-id/5476191) and welcome to the Community!

Artifact in bitbucket are used to share files between different steps. In the example that you shared, you have a single step only, so artifacts are not really being used (the after-script section is considered part of the same step, it does not run in a separate container).

Having said that, my understanding is that your repository contains a file named results.xml, but during the pipelines, you create an updated version or this file, and want to use this updated version in the rest of the commands.

It would be important to validate if the results.xml file is actually being updated by the commands you're executing, so I would suggest printing the output of that file in different sections of your build :

```
script:

- cat results.xml #1 print the original file present in the repo
- npm ci
- npx playwright test --reporter=html,junit
- cat test-results/junit.xml #2 print the file generated by playwright
- mv test-results/junit.xml results.xml
- cat results.xml #3 print the file to check if the file content was updated with the content generated by previous commands

after-script:
- |
cat results.xml # print the file to see if the content matches with #3
echo "Checking for test results file..."?
```

This would help to identify at which point of your build the file is not getting updated, so you can make the necessary changes.

Thank you, [@ragsagarm](/t5/user/viewprofilepage/user-id/5476191) !

Patrik S


Tags: bitbucket-cloud

cloud