2014-10-31 47 views
1

CI Jenkins以非root用户身份运行在CentOS无头机器上。Xvfb和thucydides/Selenium运行Firefox的默认路径

的Xvfb packege安装,当我尝试从提示How can I specify a display?,即在控制台

export DISPLAY=127.0.0.1:0 
Xvfb :0 
firefox & 

手动设置和它的作品 - 此XVFB输出显示一些Firefox的请求,火狐输出到控制台。

当我从maven运行相同的东西时,没有任何反应。请检阅我的pom.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<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>somegrouppegas</groupId> 
    <artifactId>pegas</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>jar</packaging> 
    <name>pegas</name> 


    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <thucydides.version>0.9.273</thucydides.version> 
     <thucydides.jbehave.version>0.9.273</thucydides.jbehave.version> 
     <webdriver.driver>firefox</webdriver.driver> 
     <actualVersion>0.9.7.1-BETA</actualVersion> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>net.thucydides</groupId> 
      <artifactId>thucydides-core</artifactId> 
      <version>${thucydides.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>net.thucydides</groupId> 
      <artifactId>thucydides-junit</artifactId> 
      <version>${thucydides.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>net.thucydides</groupId> 
      <artifactId>thucydides-jbehave-plugin</artifactId> 
      <version>${thucydides.jbehave.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-simple</artifactId> 
      <version>1.6.1</version> 
     </dependency> 
     <dependency> 
      <groupId>org.easytesting</groupId> 
      <artifactId>fest-assert</artifactId> 
      <version>1.4</version> 
     </dependency> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.11</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>com.googlecode.lambdaj</groupId> 
      <artifactId>lambdaj</artifactId> 
      <version>2.3.3</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.ftpserver</groupId> 
      <artifactId>ftpserver-core</artifactId> 
      <version>1.0.6</version> 
     </dependency> 
     <dependency> 
      <groupId>com.javadocmd</groupId> 
      <artifactId>simplelatlng</artifactId> 
      <version>RELEASE</version> 
     </dependency> 
     <!--<dependency> 
      <groupId>com.github.arachnidium</groupId> 
      <artifactId>arachnidium-app-model</artifactId> 
      <version>${actualVersion}</version> 
     </dependency> --> 
    </dependencies> 
    <build> 
     <plugins> 
      <!-- 
      XMInd plugin is not needed right now; it will be added after it will be improved 
      <plugin> 
       <groupId>mavenplugintest</groupId> 
       <artifactId>mavenplugintest</artifactId> 
       <version>1.0-SNAPSHOT</version> 
       <configuration> 
        <xmindpath>parse.xmind</xmindpath> 
       </configuration> 
       <executions> 
        <execution> 
         <id>generateStoriesFromXMind</id> 
         <phase>validate</phase> 
         <goals> 
          <goal>generateStoriesFromXMind</goal> 
         </goals> 
        </execution> 
        <execution> 
         <id>generateXMindFromTestResults</id> 
         <phase>post-integration-test</phase> 
         <goals> 
          <goal>generateXMindFromTestResults</goal> 
         </goals> 
        </execution> 

       </executions> 
      </plugin> --> 

      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-surefire-plugin</artifactId> 
       <version>2.17</version> 
       <configuration> 
        <forkCount>0</forkCount> 
        <skip>true</skip> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-failsafe-plugin</artifactId> 
       <version>2.17</version> 
       <configuration> 
        <forkCount>0</forkCount> 

        <includes> 
         <include>**/*Test.java</include> 
         <include>**/Test*.java</include> 
         <include>**/When*.java</include> 
         <include>**/*TestSuite.java</include> 
        </includes> 
       </configuration> 
       <executions> 
        <execution> 
         <goals> 
          <goal>integration-test</goal> 
          <goal>verify</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>2.3.2</version> 
       <configuration> 
        <source>1.7</source> 
        <target>1.7</target> 
        <!--<compilerArguments> 
         <endorseddirs>${endorsed.dir}</endorseddirs> 
        </compilerArguments> --> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-javadoc-plugin</artifactId> 
       <version>2.9</version> 
      </plugin> 
      <plugin> 
       <groupId>net.thucydides.maven.plugins</groupId> 
       <artifactId>maven-thucydides-plugin</artifactId> 
       <version>${thucydides.version}</version> 
       <executions> 
        <execution> 
         <id>thucydides-reports</id> 
         <phase>post-integration-test</phase> 
         <goals> 
          <goal>aggregate</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 

    <profiles> 
     <profile> 
      <id>maven2</id> 
      <activation> 
       <file> 
        <missing>${basedir}</missing> 
       </file> 
      </activation> 
      <reporting> 
       <plugins> 
        <plugin> 
         <groupId>net.thucydides.maven.plugins</groupId> 
         <artifactId>maven-thucydides-plugin</artifactId> 
         <version>${thucydides.version}</version> 
        </plugin> 
       </plugins> 
      </reporting> 
     </profile> 
     <profile> 
      <id>jenkins</id> 
      <build> 
       <plugins> 
        <plugin> 
         <groupId>org.codehaus.mojo</groupId> 
         <artifactId>selenium-maven-plugin</artifactId> 
         <version>2.3</version> 
         <executions> 
          <execution> 
           <id>xvfb</id> 
           <phase>pre-integration-test</phase> 
           <goals> 
            <goal>xvfb</goal> 
           </goals> 
           <configuration> 
            <display>:0</display> 
           </configuration> 
          </execution> 
          <execution> 
           <id>start</id> 
           <phase>pre-integration-test</phase> 
           <goals> 
            <goal>start-server</goal> 
           </goals> 
           <configuration> 
            <background>true</background> 
            <logOutput>true</logOutput> 
           </configuration> 
          </execution> 
          <execution> 
           <id>stop</id> 
           <phase>post-integration-test</phase> 
           <goals> 
            <goal>stop-server</goal> 
           </goals> 
          </execution> 
         </executions> 
        </plugin> 
       </plugins> 
      </build> 
     </profile> 
     <profile> 
      <id>maven3</id> 
      <activation> 
       <file> 
        <exists>${basedir}</exists> 
       </file> 
      </activation> 
      <build> 
       <plugins> 
        <plugin> 
         <groupId>org.apache.maven.plugins</groupId> 
         <artifactId>maven-site-plugin</artifactId> 
         <version>3.2</version> 
         <configuration> 
          <reportPlugins> 
           <plugin> 
            <groupId>net.thucydides.maven.plugins</groupId> 
            <artifactId>maven-thucydides-plugin</artifactId> 
            <version>${thucydides.version}</version> 
           </plugin> 
          </reportPlugins> 
         </configuration> 
        </plugin> 
       </plugins> 
      </build> 
     </profile> 
    </profiles> 
</project> 

火狐和Xvfb来公用事业chowned对于詹金斯Linux用户和chmoded 777,这样的权限不是问题的根源。

export DISPLAY=127.0.0.1:0 

设置为预生成操作。 Xvfb应该由maven selenium插件启动,并根据mavn输出和自己的Xvfb日志启动。

我想知道Thucydides/Selenium如何定义如何找到运行的Firefox二进制文件?可能他们应该明确配置jenkins配置文件?

回答

1

实际上,我无法按照我喜欢的方式解决问题,因为尽管有DISPLAY变量的任何组合,将文件和二进制文件归属到jenkins用户并回到根目录,但是无法从maven运行Xvfb插件配置。但是,Xvfb Jenkins插件工作正常!如果对我来说更完美一些,因为我不再需要不同的mvn配置文件在本地机器上和CI上运行(Xvfb插件的运行存储为jenkins配置文件),因此我需要