allure-docker-service
allure-docker-service copied to clipboard
Report history not generated correctly when project name includes the string 'latest'
I have a project name named foo-latestcommit-dmo
.
I noticed that when generating the reports via the /generate-report
endpoint, it always regenerates report #1
and never generates report #2
The project files inside the container always looks like this:
$ ls -td allure-docker-api/static/projects/foo-latestcommit-dmo-dmo/reports/*
allure-docker-api/static/projects/foo-latestcommit-dmo/reports/emailable-report-allure-docker-service.html
allure-docker-api/static/projects/foo-latestcommit-dmo/reports/1
allure-docker-api/static/projects/foo-latestcommit-dmo/reports/latest
The problem seems to be located in the generateAllureReport.sh
script, more specifically on the command used to get the LAST_REPORT_PATH_DIRECTORY https://github.com/fescobar/allure-docker-service/blob/ce7b3eb600786f8ff9099302f510948013739c5d/allure-docker-scripts/generateAllureReport.sh#L15
That command returns an empty result. However you would expect it to return allure-docker-api/static/projects/foo-latestcommit-dmo/reports/1
, which would mean report #2
would be the next one to be generated.
The reason is because grep -v latest
will filter out all the lines returned by ls
given that the project name foo-latestcommit-dmo
includes the string latest
.
The fix could be replacing grep -v latest
with grep -v /latest
Thanks, @DaniJG . It's a good catch.
Even with your fix, I realized we have the same issue using any project name starting with the word latest
. Example: latest-foo
I think the best option here is to add a validation avoiding creating projects starting with latest
in the create project endpoint (POST /project
).
What do you think? If you agree I can add that validation.
Could we not update the grep commands in the scripts to ensure a full match rather than a partial, ie something like grep -v /latest$
?
Ie ensure those grep commands match something like projects/my-project/reports/latest
but not projects/latest-foo/reports/1
@DaniJG Sorry for the long delay. The fix will be released in version 2.27.0