Jenkins搭建的幾個坑記下

海鳥發表於2015-05-28

坑一

安裝cobertura外掛後,一定要在工程程式碼的pom.xml檔案裡新增如下外掛配置:

            <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>cobertura-maven-plugin</artifactId>
                    <version>2.2</version>
                    <configuration>
                        <formats>
                            <format>xml</format>
                        </formats>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>cobertura</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

官方原文說明如下

You can either, enable "cobertura" analysis in your 'pom.xml' files or just tell Jenkins to run "cobertura" goal.
If you don't want to change your pom files, just add the goal 'cobertura:cobertura' to your Maven project in Jenkins.

這個說法以我的英文水平理解,完全是坑啊,因為我只是在Jenkins裡配置了"cobertura"goal,根本沒有效啊。

坑二

在jdk7下執行的Jenkins,會報如下錯:

java.lang.VerifyError: Expecting a stackmap frame at branch target 245
Exception Details:
  Location:
    xx.xx.xx.A.class()V @220: ifle
  Reason:
    Expected stackmap frame at this location.
  Bytecode:

原因就是這個cobertura對jdk7支援不友好,解決方法還是在你的工程pom.xml檔案裡配置如下:

             <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.12</version>
                <configuration>
                    <argLine>-XX:-UseSplitVerifier</argLine>
                </configuration>
            </plugin>

網上很多說在Jenkins的配置皮膚裡配置“Global MAVEN_OPTS”的值為“-XX:-UseSplitVerifier”,根本是沒有用的。原因可能是這裡說的

相關文章