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
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..."
echo "Adding HTML artifact to Testmo..."
testmo automation:resources:add-artifact \
--name "HTML Report" \
--file "playwright-report/index.html" \
echo "Updating Testmo with test results..."
testmo automation:run:submit \
--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