Integration of Allure reports with Gitlab

deepti bhovi
4 min readMay 25, 2020

One of the best practices in the CI/CD pipeline is to include automation. I have attempted to integrate functional automation test reports with Gitlab CI/CD.

Why allure report? simply because of its comprehensive and nice-looking feature.

As part of this article I am using the Maven project of RestAssured and TestNG framework and also using Kubernetes for the deployment of the code.

Our main goal is to publish the generated Allure report on this URL testingallurereports.com

Let’s begin

  1. The First Step would be to make necessary changes required to integrate allure reports in the Project.

POM.xml

Add the properties

Add the properties

Add the dependencies

Add the plugins

Create an allure.properties file in the resource path and add this line. This means the allure-results will be created in the target folder

2. In the second step, we will be creating 3 files in the repository

  1. .gitlab-ci.yml this file instructs the GitLab CI/CD how to build and deploy the code
  2. Your repositoryname.yml file this is Kubernetes deployment file for example in our case its acceptance-tests.yml
  3. Create a folder with name docker -> Create a Dockerfile.

Structure of Dockerfile

In dockerfile we are using the apache image because we need a webserver to serve the allure report generated in this path \target\site\allure-maven-plugin\index.html file So, Copy this index.html and save it in htdocs path and give the port no.

Structure of .gitlab-ci.yml

There are Four stages

a) In the build stage we will execute our test cases using mvn script for which we will need maven3 docker image. Post execution of the script we store the code in one of the repository created in AWS elastic container service. (Kubernetes is managing on EC2 instances).

b) In the prepare stage we will be creating an image tag.

c) In the package stage we will be creating an image of this repository code on top of the base image mentioned in dockerfile and push this image.

d) In the deploy stage we first pull the docker image and run Kubernetes script for the deployment of the code.

Structure of acceptance-tests.yml

In this file, we mention about latest build image and in env variable add the URL name

So far we were able to generate the report and deploy the image. Now one final step is remaining that is Kubernetes has successfully deployed in one of the containers in order to access data outside the container we need Kubernetes ingress. In the final step create 2 more files in the docker folder i.e

ingress.yml

Mention about the host value

services.yml

Mention about protocol

Finally when we deploy the code and hit the URL testingallurereports.com report looks like this.

If you have reached till here. Thanks for reading :)

--

--