2017-02-15 44 views
1

我想更新jenkins selenium插件(最新版本:2.53.1)。 我可以在jenkins之外配置selenium集线器和节点,并且使用最新的浏览器版本(firefox 51.0.1,chrome 55.0.2883.87)成功运行我的自动化测试,但我只是想用jenkins作为集线器。将jenkins selenium插件更新到3.0.1版

因此,这就是为什么我试图将最新版本的selenium-server-standalone(3.0.1)集成到Jenkins中,但它不起作用。

收到此错误信息:

[WARNING] The POM for org.jenkins-ci.tools:maven-hpi-plugin:jar:1.117 is missing, no dependency information available 
[WARNING] Failed to build parent project for org.jenkins-ci.plugins:selenium:hpi:2.53.2-SNAPSHOT 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO]Building Jenkins Selenium Plugin 2.53.2-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-hpi-plugin:1.117:validate (default-validate) @ selenium --- 
[INFO] 
[INFO] --- maven-enforcer-plugin:1.3.1:display-info (display-info) @ selenium --- 
[INFO] Maven Version: 3.3.9 
[INFO] JDK Version: 1.8.0_121 normalized as: 1.8.0-121 
[INFO] OS Info: Arch: amd64 Family: unix Name: linux Version: 4.4.0-62-generic 
[INFO] 
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (display-info) @ selenium --- 
[INFO] Restricted to JDK 1.7 yet org.seleniumhq.selenium:selenium-server-standalone:jar:3.0.1:compile contains org/openqa/selenium/chrome/ChromeDriver.class targeted to JDK 1.8 
[WARNING] Rule 2: org.apache.maven.plugins.enforcer.EnforceBytecodeVersion failed with message: 
Found Banned Dependency: org.seleniumhq.selenium:selenium-server-standalone:jar:3.0.1 
Use 'mvn dependency:tree' to locate the source of the banned dependencies. 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] 
------------------------------------------------------------------------ 
[INFO] Total time: 11.325 s 
[INFO] Finished at: 2017-02-15T16:42:25+01:00 
[INFO] Final Memory: 62M/1133M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce (display-info) on project selenium: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException 

Maven项目的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/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>fake</groupId> 
    <artifactId>fake</artifactId> 
    <packaging>pom</packaging> 
    <version>${selenium.version}</version> 

    <name>fake</name> 

    <properties> 
     <selenium.short.version>3.0</selenium.short.version> 
     <selenium.version>${selenium.short.version}.1</selenium.version> 
     <htmlunit.driver.version>2.20</htmlunit.driver.version> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-antrun-plugin</artifactId> 
       <version>1.7</version> 
       <executions> 
        <execution> 
         <phase>install</phase> 
         <goals> 
          <goal>run</goal> 
         </goals> 
         <configuration> 
          <target> 
           <get 
            src="http://selenium-release.storage.googleapis.com/${selenium.short.version}/selenium-server-standalone-${selenium.version}.jar" 
            dest="${project.build.directory}/selenium-server-standalone-${selenium.version}.jar" 
            verbose="on" usetimestamp="true" /> 
           <get 
            src="https://github.com/SeleniumHQ/htmlunit-driver/releases/download/${htmlunit.driver.version}/htmlunit-driver-standalone-${htmlunit.driver.version}.jar" 
            dest="${project.build.directory}/htmlunit-driver-standalone-${htmlunit.driver.version}.jar" 
            verbose="on" usetimestamp="true" /> 
          </target> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-install-plugin</artifactId> 
       <version>2.5.1</version> 
       <executions> 
        <execution> 
         <id>selenium-server-standalone</id> 
         <phase>install</phase> 
         <goals> 
          <goal>install-file</goal> 
         </goals> 
         <configuration> 
          <file>${project.build.directory}/selenium-server-standalone-${selenium.version}.jar</file> 
          <groupId>org.seleniumhq.selenium</groupId> 
          <artifactId>selenium-server-standalone</artifactId> 
          <version>${selenium.version}</version> 
          <packaging>jar</packaging> 
          <localRepositoryPath>local_m2</localRepositoryPath> 

         </configuration> 
        </execution> 
        <execution> 
         <id>htmlunit-driver-standalone</id> 
         <phase>install</phase> 
         <goals> 
          <goal>install-file</goal> 
         </goals> 
         <configuration> 
          <file>${project.build.directory}/htmlunit-driver-standalone-${htmlunit.driver.version}.jar</file> 
          <groupId>org.seleniumhq.selenium</groupId> 
          <artifactId>htmlunit-driver-standalone</artifactId> 
          <version>${htmlunit.driver.version}</version> 
          <packaging>jar</packaging> 

          <localRepositoryPath>local_m2</localRepositoryPath> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

代码:https://github.com/jenkinsci/selenium-plugin

操作系统:Ubuntu的16.04.2; Eclipse霓虹Java IDE,openjdk版本“1.8.0_121”

我已经尝试过openjdk 1.7,但它仍然无法正常工作。

我在这是一个新手,所以我很感激任何帮助。非常感谢。

回答

0

根本原因很简单:Jenkins插件的父pom默认强制执行到JDK7。硒库已经开始使用JDK8。这解释了执行者插件引起的错误消息。

这里是如何的实施者插件已经在parent pom

<java.level>7</java.level>

<enforceBytecodeVersion> 
    <maxJdkVersion>1.${java.level}</maxJdkVersion> 
    <ignoredScopes> 
    <ignoredScope>test</ignoredScope> 
    </ignoredScopes> 
    <excludes> 
    <!-- Makes no sense to check core itself: --> 
    <exclude>org.jenkins-ci.main:jenkins-core</exclude> 
    <exclude>org.jenkins-ci.main:cli</exclude> 
    <exclude>org.jenkins-ci.main:jenkins-test-harness</exclude> 
    <!-- findbugs dep managed to provided and optional so is not shipped and missing annotations ok --> 
    <exclude>com.google.code.findbugs:annotations</exclude> 
    </excludes> 
</enforceBytecodeVersion> 

被配置为解决这个问题,你有两个选择[我从来没有尝试过这一点,但它的东西,你可以尝试看看它是否有帮助](这两个选项我建议根据您父母本身的建议本身)

  • 尝试传递JVM参数-Djava.level=8当你建立的代码。
  • 添加一个条目,如下面的POM文件(这将导致执法插件或许忽略只有硒库)

    Maven的实施者 - 插件 显示信息 组织.seleniumhq.selenium:selenium-java::jar:compile org.seleniumhq.selenium:selenium-server::jar:compile

希望帮助!

更新 我花了更多的时间看这个,并意识到转移到硒3.0.1这个插件并不是非常简单。我已经尝试做了更改,并提出了相同的pull request。你可以看看公关,看看是否有帮助。 PS:我还有3次测试未能通过公关测试。我还没有想出如何让他们通过。但公关应该可以帮助你开始。你可以直接检查我的分支并尝试从那里建设。

+0

感谢您的快速响应和帮助。我明白原因,我试过了你的选择。不幸的是,这些选项都没有工作。错误消息: - 第一个选项 ... [INFO] BUILD FAILURE ... [ERROR]无法执行目标org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce(display- info):目标org.apache.maven.plugins的执行显示信息:maven-enforcer-plugin:1.3.1:强制执行失败:给出未知的JDK版本。应该是像“1.7” - > [Help 1] ...你有其他想法吗?我感谢您的帮助。谢谢。 –

+0

@ Jaw.M.-我已经更新了我的答案。请看看并接受它,如果它有帮助。 –

+0

非常感谢您的帮助。是否需要将htmlunit-driver-standalone更改为版本3.0.1?最新的官方版本是2.20。当我用3.0.1版本和你的pr更改进行尝试时,我遇到了一些问题:... [错误]无法执行项目硒目标:无法解析项目org.jenkins-ci的依赖关系。插件:selenium:hpi:2.53.2-SNAPSHOT:未能找到org.seleniumhq.selenium:htmlunit-driver-standalone:jar:3.0.1 in file:///home/.../git/selenium-plugin/ dist-server-standalone/local_m2被缓存在本地存储库中 –

相关问题