fixed csfr token for allure in test.yml

This commit is contained in:
Jan 2026-02-08 19:51:15 +01:00
parent 448943dfe2
commit d2960bc892

View file

@ -51,29 +51,38 @@ jobs:
- name: Upload to Allure
if: always()
run: |
# Login und Cookie speichern
# Login und Cookies speichern
curl -s -c cookies.txt \
-X POST "${ALLURE_SERVER}/allure-docker-service/login" \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"${{ secrets.ALLURE_PASSWORD }}"}'
# CSRF Token aus Cookie extrahieren
CSRF_TOKEN=$(grep csrf_access_token cookies.txt | awk '{print $7}')
# Create project
curl -s -o /dev/null -b cookies.txt \
-H "X-CSRF-TOKEN: ${CSRF_TOKEN}" \
-X POST "${ALLURE_SERVER}/allure-docker-service/projects" \
-H "Content-Type: application/json" \
-d '{"id": "'${ALLURE_PROJECT}'"}' || true
-d '{"id":"'${ALLURE_PROJECT}'"}' || true
# Clean results
curl -s -b cookies.txt \
curl -s -o /dev/null -b cookies.txt \
-H "X-CSRF-TOKEN: ${CSRF_TOKEN}" \
"${ALLURE_SERVER}/allure-docker-service/clean-results?project_id=${ALLURE_PROJECT}"
# Upload files
for f in target/allure-results/*; do
[ -f "$f" ] && curl -s -b cookies.txt \
[ -f "$f" ] && curl -s -o /dev/null -b cookies.txt \
-H "X-CSRF-TOKEN: ${CSRF_TOKEN}" \
-X POST "${ALLURE_SERVER}/allure-docker-service/send-results?project_id=${ALLURE_PROJECT}" \
-F "results[]=@$f"
done
# Generate report
curl -s -b cookies.txt \
"${ALLURE_SERVER}/allure-docker-service/generate-report?project_id=${ALLURE_PROJECT}"
-H "X-CSRF-TOKEN: ${CSRF_TOKEN}" \
"${ALLURE_SERVER}/allure-docker-service/generate-report?project_id=${ALLURE_PROJECT}"
echo "Allure upload complete"