[Automated testing] How to build allure in jenkins

I believe that everyone will use automated testing environments when doing automated testing. Currently, the most common one is to deploy automated testing environments through containerization. However, some test novices are not very good at building continuous integration environments, especially from 0- In the process of 1, you need to build many dependent environments by yourself. Today I will introduce to you how to build allure in jenkins and the environments that allure depends on.

1. Install JDK

1. Download jdk

Method 1: Download the specified version directly through the command

Method 2: Download from the official website and transfer to Linux system

2. Unzip jdk

tar -zxvf  jdk-19_linux-x64_bin.tar.gz

3. Configure java environment variables

3-1 If there is no vim command in the jenkins container, you need to install vim

apt-get update 
apt-get install vim

3-2 Edit the configuration file and add environment variables

 vim /etc/profile

picture

3-3 Save and exit after editing, use the following command

source /etc/profile

3-4 Verify whether the configuration is successful

picture

2. Install allure

1. Unzip allure

1-1 Copy the file from the host to the container and decompress it

复制allure安装包
docker cp /var/allure-2.21.0.tgz jenkins:/usr/local/src
解压文件
tar -zxvf allure-2.21.0.tgz

1-2 Give the highest permissions to all contents of the folder

chmod -R 777 allure  # allure安装所在目录

2. Configure environment variables

2-1 The configuration method is similar to jdk, edit the environment variables and save

vim /etc/profile 
# 编辑内容
export PATH=$PATH:/usr/local/src/allure/bin  # allure的安装目录

Insert image description here

2-2 Make environment variables effective

source /etc/profile

2-3 Verify whether the configuration is successful

picture

Note: If the environment variables set do not take effect every time you enter the Jenkins container, you need to execute the source command every time. This can be solved by adding the following command to the configuration file.

# 编辑bashrc文件
vim ~/.bashrc
# 添加source命令,并保存
source /etc/profile
# 重启容器,即可解决该问题
docker restart jenkins

3. Configure all

1. Install allure plug-in

Search for: allure in the "Available plugins" list in "System Management"->"Plugins" in Jenkins, and then click: install. After installation, you can view the plugin in "Installed plugins". If "Enabled" is displayed, the installation is successful.

picture

2. Configure JDK environment

Configure JDK in Jenkins' "System Management"->"Global Tool Configuration"

picture

3. Configure allure environment

Configure allure in Jenkins' "System Management"->"Global Tool Configuration"

picture

4. Add allure post-build operations

4-1 Add "Allure Report" in the project's "Configuration"->"Post-Build Operations"

picture

4-2 Add the saving directory of allure report files in "Build Steps", which must be consistent with the path directory of allure in "Post-Build Operations"

picture

5. Achieve results

5-1 Click the "Build Now Button" in the project workspace, and then view the generated allure report

picture

Insert image description here

6. Modify the time zone of jenkins

Note: If you find that the time in Jenkins is inconsistent with the actual time, it is most likely a time zone problem, so you need to modify the time zone in the Jenkins container.

6-1. Enter the container using root identity

docker exec -it -u root jenkins /bin/bash

6-2 Check the time zone of the container and find that the time zone is ETC/UTC

picture

6-3 Modify the time zone of the container to: Asia/Shanghai

picture

6-4 Exit the container and restart the container

docker restart jenkins

6-5 In jenkins system management->system properties->user.timezone field changes to: Asia/Shanghai, it is successful.

picture

Finally, I would like to thank everyone who reads my article carefully. Reciprocity is always necessary. Although it is not a very valuable thing, if you can use it, you can take it directly:

Insert image description here

This information should be the most comprehensive and complete preparation warehouse for [software testing] friends. This warehouse has also accompanied tens of thousands of test engineers through the most difficult journey. I hope it can also help you!   

Guess you like

Origin blog.csdn.net/YLF123456789000/article/details/132807452