Example project using GitLab CI/CD for Allure report with history on GitLab Pages. Project mirror on GitLab.
You can see Allure Report on GitLab Pages.
Learn how to use GitLab CI/CD on official docs.
Here are my advices:
- You need to create workflow in
.gitlab-ci.yml
in project root. Example workflow .gitlab-ci.yml. - This workflow uses GitLab Job artifacts to pass allure-results from job to job through stages. Read more about Job artifacts.
- There are three stages: test, report, deploy. Read more about GitLab Pipeline Architecture.
- test (tests execution, passing allure-results to artifacts)
- report (generating allure-report, passing allure-report to artifacts)
- deploy (publishing allure-report on GitLab Pages from artifacts)
Learn how to use GitLab Pages on official docs.
Here are my advices:
- Go to your repository Settings-> General->Visibility scroll down to Pages and ensure the feature is enabled. Also, you can choose visibility for everyone or for project members only.
- Create a separate branch which will store your allure-reports on GitLab Pages, to not store full allure-report history at master. For example 'gl-pages'.
- Create in branch 'gl-pages' a
.gitlab-ci.yml
file with jobpages
, stagedeploy
and artifactspublic
, example:stages: - deploy pages: image: alpine stage: deploy script: - echo "Publish to GitLab Pages" artifacts: paths: - public
- Commit your reports with indexed report tree to 'gl-pages'
/public
directory. - Every time you push a commit to 'gl-pages', the 'pages' job will publish all the public directory has on GitLab Pages.
Here is how it works:
- Job 'test' is running tests on your current branch and saves allure-results to artifacts for the next job in pipeline.
- Job 'allure':
- Clones 'gl-pages' branch into container with a copy of all 'gl-pages' branch files (previous reports).
- Gets the 'history' of the last build from the same branch (if exists) into 'allure-results' of current build.
- Creates 'executor.json' in 'allure-results' with build info and buildUrls in trends.
- Generates report with allure Commandline into job_number build folder.
- Creates branch-dir in 'gl-pages'
/public
directory if it's not existed yet. - Copies report into 'gl-pages'
/public/branch
directory:/public/branch/job_number
. - Generates the index files for page tree
/public
and/public/branch
. - Commits and pushes the public directory into 'gl-pages' branch into the repo.
- And then push to branch 'gl-pages' triggers it's own job
pages
which publishes all content from/public
directory on GitLab Pages. You can open root link of GitLab Pages and always see all the history of each branch and find the latest execution by the latest job_number inside the branch-dir of the branch you are interested in.