Installing a plug-in

  1. Search to install the Allure Jenkins Plugin
  2. Manage Jenkins-> Global Tool Configuration with the following Settings:

Automatically install Allure when Jenkins checks that Allure is not installed

POM configuration

  1. Build-> plugins edit the following plugins

    <! > <plugin> < grouppid >org.apache.maven.plugins</ grouppid > <artifactId>maven-surefire-plugin</artifactId> <configuration> <! -- Default report directory is target/surefire-reports/ --> <! --reportsDirectory>target/test-reports/</reportsDirectory>--> <argLine> -javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar  </argLine> <properties> <property> <name>listener</name> <value>io.qameta.allure.junit4.AllureJunit4</value> </property> </properties> <systemProperties> <property> <name>allure.result.directory</name> <value>${project.build.directory}/allure-results/</value> </property> <property> <name>allure.link.issue.pattern</name> <value>http://example.org/issue/{}</value> </property> </systemProperties> </configuration> <dependencies> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>${aspectj.version}</version> </dependency> </dependencies> </plugin>
  2. Add the following dependencies to dependencies

    <! Allure </ grouppid > <artifactId> Allure -junit4</artifactId> < version > 2.9.0 < / version > < scope > test < / scope > < / dependency >

Notes: The maven-surefire-plugin and allure-junit4 need to be added to their respective versions

Jenkinsfile

  1. Dashboard -> {project name} -> {branch name} -> Pipeline Syntax, get allure command
  2. Modify JenkinsFile as follows

    Pipeline {agent any tools {maven "maven-3.6.3"} stages {stage ("UnitTest") {steps { configFileProvider([configFile(fileId: "mvn-setting-hhw", variable: "MVN_HHW")]) { sh "mvn -s ${MVN_HHW} test" } } } } post { always { script { allure includeProperties: false, jdk: '', results: [[path: 'target/allure-results/']] } } } }
    • sh "mvn -s ${MVN_HHW} test"Run the Test task with the specified Maven configuration file
    • post -> always -> script -> allureThe allure operation is always run after the stages are complete

The results of

  1. The build results are as follows
  2. Allure reports below

    Click on theAllure reportEnter the Allure report

Junit5

  1. pom.xml -> build -> plugins

    <! > <plugin> <artifactId>maven-surefire-plugin</artifactId> <configuration> <testFailureIgnore>false</testFailureIgnore> <argLine> -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.ja r" </argLine> <systemProperties> <property> <name>junit.jupiter.extensions.autodetection.enabled</name> <value>true</value> </property> </systemProperties> <reportsDirectory>target/allure-reports/</reportsDirectory> </configuration> <dependencies> <dependency> <groupId>org.junit.platform</groupId> < artifactId > junit - platform - surefire - provider < / artifactId > < version > 1.2.0 < / version > < / dependency > < the dependency > <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>${aspectj.version}</version> </dependency> </dependencies> </plugin> <plugin> <groupId>io.qameta.allure</groupId> The < artifactId > allure - maven < / artifactId > < version > 2.10.0 < / version > < configuration > < reportVersion > against 2.4.1 < / reportVersion > </configuration> </plugin>
  2. pom.xml -> dependencys

    <! - Allure beautification test report - > < the dependency > < groupId >. IO qameta. Allure < / groupId > < artifactId > Allure - junit5 < / artifactId > < version > 2.9.0 < / version > < scope > test < / scope > < / dependency >