allure-docker-service icon indicating copy to clipboard operation
allure-docker-service copied to clipboard

Report history not generated correctly when project name includes the string 'latest'

Open DaniJG opened this issue 2 years ago • 2 comments

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

DaniJG avatar Nov 30 '22 12:11 DaniJG

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.

fescobar avatar Feb 24 '23 11:02 fescobar

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 avatar Feb 24 '23 11:02 DaniJG

@DaniJG Sorry for the long delay. The fix will be released in version 2.27.0

fescobar avatar Mar 12 '24 22:03 fescobar