问题
I am trying to deploy allure report which was generated after "mvn clean test site". I have used mvn jetty:run and when I tried to open "http://localhost:8080", I got a "Directory:/" as a text in firefox browser instead of actual Allure report.
Output of jetty server
Error Section
No Error
pom.xml
<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.mycomp</groupId>
<artifactId>AllureWebDriverMvnProj</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<allure.version>1.5.0-RC1</allure.version>
<aspectj.version>1.8.7</aspectj.version>
</properties>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.9</version>
</dependency>
<dependency>
<groupId>ru.stqa.selenium</groupId>
<artifactId>webdriver-factory</artifactId>
<version>1.1.46</version>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-testng-adaptor</artifactId>
<version>${allure.version}</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<configuration>
<filesets>
<fileset>
<directory>${basedir}/target/site</directory>
<directory>${basedir}/target/allure-results</directory>
</fileset>
</filesets>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
<suiteXmlFile>src/test/resources/testng_demo.xml</suiteXmlFile>
</suiteXmlFiles>
<argLine>
-javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar
</argLine>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.11.v20150529</version>
<configuration>
<configuration>
<webAppSourceDirectory>../AllureWebDriverMvnProj/target/site/allure-maven-plugin/</webAppSourceDirectory>
<stopKey>stop</stopKey>
<stopPort>1234</stopPort>
</configuration>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<excludeDefaults>true</excludeDefaults>
<plugins>
<plugin>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-maven-plugin</artifactId>
<version>2.4</version>
</plugin>
</plugins>
</reporting>
<!-- profiles -->
<profiles>
<!-- browsers -->
<profile>
<id>firefox</id>
<properties>
<capabilities>/firefox.capabilities</capabilities>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>chrome</id>
<properties>
<capabilities>/chrome.capabilities</capabilities>
</properties>
</profile>
<profile>
<id>ie</id>
<properties>
<capabilities>/ie.capabilities</capabilities>
</properties>
</profile>
<profile>
<id>safari</id>
<properties>
<capabilities>/safari.capabilities</capabilities>
</properties>
</profile>
<profile>
<id>phantomjs</id>
<properties>
<capabilities>/phantomjs.capabilities</capabilities>
</properties>
</profile>
<profile>
<id>opera</id>
<properties>
<capabilities>/opera.capabilities</capabilities>
</properties>
</profile>
<profile>
<id>htmlunit</id>
<properties>
<capabilities>/htmlunit.capabilities</capabilities>
</properties>
</profile>
<!-- environments -->
<profile>
<id>localhost</id>
<properties>
<site.url>http://localhost/</site.url>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>devhost</id>
<properties>
<site.url>http://devhost/</site.url>
</properties>
</profile>
<profile>
<id>testhost</id>
<properties>
<site.url>http://testhost/</site.url>
</properties>
</profile>
<profile>
<id>prodhost</id>
<properties>
<site.url>http://prodhost.com/</site.url>
</properties>
</profile>
<!-- grid -->
<profile>
<id>nogrid</id>
<properties>
<grid.url></grid.url>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>grid</id>
<properties>
<grid.url>http://localhost:4444/wd/hub/</grid.url>
</properties>
</profile>
</profiles>
</project>
Console Output
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building AllureWebDriverMvnProj 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> jetty-maven-plugin:9.2.11.v20150529:run (default-cli) @ AllureWebDriverMvnProj >>>
[INFO]
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ AllureWebDriverMvnProj ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ AllureWebDriverMvnProj ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) @ AllureWebDriverMvnProj ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 11 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ AllureWebDriverMvnProj ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< jetty-maven-plugin:9.2.11.v20150529:run (default-cli) @ AllureWebDriverMvnProj <<<
[INFO]
[INFO] --- jetty-maven-plugin:9.2.11.v20150529:run (default-cli) @ AllureWebDriverMvnProj ---
2015-11-10 13:38:35.132:INFO::main: Logging initialized @9160ms
[INFO] Configuring Jetty for project: AllureWebDriverMvnProj
[INFO] webAppSourceDirectory not set. Trying src\main\webapp
[INFO] webAppSourceDirectory E:\Selenium\eclipse-jee-luna-SR2-win32\Luna_Workspace_new\AllureWebDriverMvnProj\src\main\webapp does not exist. Trying E:\Selenium\eclipse-jee-luna-SR2-win32\Luna_Workspace_new\AllureWebDriverMvnProj\target\webapp-tmp
[INFO] Reload Mechanic: automatic
[INFO] Classes = E:\Selenium\eclipse-jee-luna-SR2-win32\Luna_Workspace_new\AllureWebDriverMvnProj\target\classes
[INFO] Context path = /
[INFO] Tmp directory = E:\Selenium\eclipse-jee-luna-SR2-win32\Luna_Workspace_new\AllureWebDriverMvnProj\target\tmp
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides = none
[INFO] web.xml file = null
[INFO] Webapp directory = E:\Selenium\eclipse-jee-luna-SR2-win32\Luna_Workspace_new\AllureWebDriverMvnProj\target\webapp-tmp
2015-11-10 13:38:35.337:INFO:oejs.Server:main: jetty-9.2.11.v20150529
2015-11-10 13:38:42.450:INFO:oejsh.ContextHandler:main: Started o.e.j.m.p.JettyWebAppContext@7d29df{/,file:/E:/Selenium/eclipse-jee-luna-SR2-win32/Luna_Workspace_new/AllureWebDriverMvnProj/target/webapp-tmp/,AVAILABLE}{file:/E:/Selenium/eclipse-jee-luna-SR2-win32/Luna_Workspace_new/AllureWebDriverMvnProj/target/webapp-tmp/}
2015-11-10 13:38:42.466:WARN:oejsh.RequestLogHandler:main: !RequestLog
2015-11-10 13:38:42.592:INFO:oejs.ServerConnector:main: Started ServerConnector@5cd81a{HTTP/1.1}{0.0.0.0:8080}[INFO] Started Jetty Server
2015-11-10 13:38:42.592:INFO:oejs.Server:main: Started @16620ms
回答1:
In maven test and site are different phases. You should run maven commands in two steps: 1. mvn clean test 2. mvn site Then you will get generated Allure report
回答2:
@Illia B, Thanks for the reply. We can mention "site" along with the "clean test". Its gonna work smoothly. The issue was with the configuration tag (By mistakenly I mentioned it twice) and the webAppSourceDirectory tag was pointing at wrong directory. I targeted it to the right path and it worked.
来源:https://stackoverflow.com/questions/33626654/unable-to-deploy-allure-report-on-jetty-server