Important Step otherwise Allure Report will keep on loading
We need to Set Jenkins with below
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';")
System.setProperty("jenkins.model.DirectoryBrowserSupport.CSP", "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';")
Enter above two commands in Script console of Jenkins and Run button
Refer below image
Enter above two commands in Script console of Jenkins and Run button
Refer below image
Install Allure Jenkins Plugin on Jenkins
Setup Jenkins Global Tool Configuration
Setup Jenkins Global Tool Configuration
Here we need to tell Jenkins Which Allure version to use
Setup Jenkins
Go To Jenkins
Click Manage
Click Configure System
Click Manage
Click Configure System
Create Multi Configuration Project
Don't create Maven or Free Style Project
Refer Below POM.XML for Allure
Note here we are using Maven Version and Java version as following
E:\MyNewFramework>mvn -version
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T01:09:06+05:30)
Maven home: C:\Program Files\Apache\apache-maven-3.5.0\bin\..
Java version: 1.7.0_67, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_67\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 8.1", version: "6.3", arch: "amd64", family: "windows"
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.neeraj</groupId> <artifactId>project</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>project</name> <url>http://maven.apache.org</url> <build> <pluginManagement> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.6.1</version> <configuration> <source>1.7</source> <target>1.7</target> <debug>true</debug> <encoding>utf-8</encoding> <optimize>true</optimize> </configuration> </plugin> <!-- <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>9.3.7.v20160115</version> <configuration> <webAppSourceDirectory>${project.build.directory}/site/allure-maven-plugin</webAppSourceDirectory> <httpConnector> <port>${jetty.http.port}</port> </httpConnector> <stopKey>stop</stopKey> <stopPort>1234</stopPort> </configuration> </plugin>--><plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.19.1</version> <configuration> <argLine> -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar" </argLine> <properties> <property> <name>listener</name> <value>ru.yandex.qatools.allure.testng.AllureTestListener</value> </property> </properties> <!-- Suite testng xml file to consider for test execution --> <suiteXmlFiles> <suiteXMLFile>${suitexml}</suiteXMLFile> </suiteXmlFiles> </configuration> </plugin>
<plugin> <groupId>io.qameta.allure</groupId> <artifactId>allure-maven</artifactId> <version>2.8</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.1</version> <executions> <execution> <phase>validate</phase> <goals> <goal>run</goal> </goals> <configuration> <tasks> <echo>Displaying 3 environment variables</echo> <echo>[COMPUTERNAME] ${env.COMPUTERNAME}</echo> <echo>[M2_HOME] ${env.M2_HOME}</echo> <echo>[Path] ${env.Path}</echo> </tasks> </configuration> </execution> </executions> </plugin> </plugins> </pluginManagement> </build> <!-- <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <aspectj.version>1.8.8</aspectj.version> <allure.version>1.4.22</allure.version> <env>test</env> </properties> --><properties> <jetty.http.port>9001</jetty.http.port> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <allure.version>1.4.24.RC3</allure.version> <aspectj.version>1.8.9</aspectj.version> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <env>test</env> </properties>
<dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency><dependency> <groupId>ru.yandex.qatools.allure</groupId> <artifactId>allure-testng-adaptor</artifactId> <version>${allure.version}</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>${aspectj.version}</version> </dependency> <dependency> <groupId>ru.yandex.qatools.htmlelements</groupId> <artifactId>htmlelements-java</artifactId> <version>1.8</version> </dependency>
<dependency> <groupId>ru.yandex.qatools.htmlelements</groupId> <artifactId>htmlelements-matchers</artifactId> <version>1.8</version> </dependency>
<dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.9.6</version> </dependency> <dependency> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.18.1</version> </dependency> <!-- https://mvnrepository.com/artifact/org.jsoup/jsoup --> <dependency> <groupId>org.jsoup</groupId> <artifactId>jsoup</artifactId> <version>1.8.3</version> </dependency> <dependency> <groupId>org.jdom</groupId> <artifactId>jdom</artifactId> <version>2.0.2</version> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>2.47.2</version> </dependency> </dependencies><reporting> <excludeDefaults>true</excludeDefaults> <plugins> <plugin> <groupId>ru.yandex.qatools.allure</groupId> <artifactId>allure-maven-plugin</artifactId> <version>2.5</version> <!-- <configuration> <reportDirectory>allure-report</reportDirectory> <resultsDirectory>allure-results</resultsDirectory> </configuration> --> </plugin> </plugins> </reporting>
</project>
Note: If you are Getting Error related to Program FIles (86)
Try to copy all Jenkins Folder to C:/Programs Files, Delete all items from C:\Program Files (x86)\Jenkins except following
In The End your report will be generated through Allure.bat present at
C:\Program Files\Jenkins\tools\ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation\1.5.4\bin
Very Important Trigger mvn test site in below manner
mvn clean test -Dsuitexml=E:\MyNewFramework\src\test\java\com\neeraj\pages\secondtestng.xml -Dmaven.test.failure.ignore=true
-Denv=test site -Dbrowser=Chrome
IN above command we are cleaning first to remover all old reports of allure created indirectly we are cleaning whatever created in last run
Now run the Job (If everything went fine Your Job Will Get Link of Allure Report Click on that and it will show you all the report)
Note Very Important
Allure Generate reports through jenkins from this location
C:\Program Files\Jenkins\jobs\TryMaven\workspace\default\target\allure-results
Here xml files are generated corresponding to every run of the job and generates Report Accordingly
Note: Some Time in newly Created Job target folder is not there, So Pls check if its there or not
No comments:
Post a Comment