allure-docker-service
allure-docker-service copied to clipboard
Export report using docker run?
This project is exactly what I need except that I need to generate to the report as part of the docker run command. Currently I can do this:
docker run -p 5050:5050 -e CHECK_RESULTS_EVERY_SECONDS=3 -e KEEP_HISTORY=1 -v "/$(pwd)/allure-results:/app/allure-results" frankescobar/allure-docker-service &
sleep 60 //not sure how to know when it's ready since I'm running in background
curl -X GET "http://localhost:5050/allure-docker-service/emailable-report/render?project_id=default" -H "accept: /" -o index.html
//Clean up so I can run it again on the next build docker kill $(docker ps | grep allure | awk '{print $1}')
The problem with this approach is that if the "clean up" step fails then my pipeline will start failing until I do manual clean up.
Just you need to run the next command after all your tests finished to execute.
docker run --rm -p 5050:5050 -e CHECK_RESULTS_EVERY_SECONDS=NONE -e KEEP_HISTORY=1 \
-v "/$(pwd)/allure-results:/app/allure-results" frankescobar/allure-docker-service \
bash -c "curl http://localhost5050/generate-report; curl http://localhost5050/emailable-report/export"
CHECK_RESULTS_EVERY_SECONDS
is disabled,
--rm
to remove your container once finished.
bash -c "..."
it's the way to run commands internally in the container
Once the container started you have to generate the report and export the results using the API. You will see your HTML generated. That's all.
Thanks @fescobar - sorry I misunderstood and thought "generate-report" was async - if it's sync then that's perfect. I'll try this out in my CICD and report back.