2014-10-31 63 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配置文件),因此我需要