为什么 Jenkins 将 instrumented jar 推广到我的存储库
why Jenkins promoting instrumented jar to my repository
我有一个问题,Jenkins 将一个经过检测的 jar 文件提升到 nexus 存储库,所以当它在 jBoss 中部署我的应用程序时抛出异常 Caused by: java.lang.NoClassDefFoundError: net/sourceforge/cobertura/coveragedata/TouchCollector
at com.premierinc.its.pfgpgrouper.service.algorithms.AbstractPopulationGrouper.__cobertura_init
詹金斯行家配置:
版本是 mvn-3.2.3
清理安装站点
我的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.myapp.its</groupId>
<artifactId>myapp</artifactId>
<version>15.2.2.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MyApp</name>
<description>
MY API.
</description>
<scm>
<connection>scm:git:ssh://git@code/pfpg/my-app.git</connection>
<developerConnection>scm:git:ssh://git@code/pfgp/my-app.git</developerConnection>
<tag>HEAD</tag>
</scm>
<distributionManagement>
<repository>
<id>code-artifacts</id>
<url>
http://code/artifacts/content/repositories/releases
</url>
</repository>
<snapshotRepository>
<id>code-artifacts</id>
<url>
http://code/artifacts/content/repositories/snapshots
</url>
</snapshotRepository>
</distributionManagement>
<properties>
<spring.version>4.0.3.RELEASE</spring.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<oracle.version>11.2.0.2.0</oracle.version>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
<configuration>
<argLine>-Xms512m -Xmx512m</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<formats>
<format>xml</format>
<format>html</format>
</formats>
</configuration>
<executions>
<execution>
<phase>site</phase>
<goals>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-jgitflow-plugin</artifactId>
<version>1.0-alpha21.1</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<pushFeatures>true</pushFeatures>
<pushHotfixes>true</pushHotfixes>
<pushReleases>true</pushReleases>
<noReleaseBuild>true</noReleaseBuild>
<noFeatureBuild>true</noFeatureBuild>
<noHotfixBuild>true</noHotfixBuild>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>myFile</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<schemaDirectory>src/main/resources/schema</schemaDirectory>
<outputDirectory>src/main/java/</outputDirectory>
<extension>true</extension>
<arguments>
-no-header -cp collection-setter-injector.jar
-Xcollection-setter-injector
</arguments>
<packageName>com.premierinc.its.pfgpgrouper.dto</packageName>
<staleFile>
${project.build.directory}/generated-sources/jaxb/patient/.staleFlag
</staleFile>
<clearOutputDir>false</clearOutputDir>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>net.java.dev.vcc.thirdparty</groupId>
<artifactId>collection-setter-injector</artifactId>
<version>0.5.0-1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.7</version>
</plugin>
<!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.1</version> </plugin> -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.17</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.13</version>
<configuration>
<configLocation>src/code-analysis/checkstyle.xml</configLocation>
</configuration>
</plugin>
</plugins>
</reporting>
<dependencies>
<!-- DB Driver -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6g</artifactId>
<version>${oracle.version}</version>
</dependency>
<!-- SPRING -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-mock</artifactId>
<version>2.0.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>5.14.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.10</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>
他们在最新版本中修复了 cobertura 的问题,请参阅此 link。
我运行遇到了同样的问题; Maven 3.2.3,cobertura-maven-plugin 2.7,詹金斯 1.608。这似乎是 Jenkins 问题而不是 cobertura 问题。
我的詹金斯工作运行主要构建步骤的 Maven 目标clean verify site:site
。
Jenkins 然后将 verify
期间生成的工件部署到 maven 存储库,但是,jar 中的 类 全部由 Cobertura 检测,导致 NoClassDefFoundErrors
在 运行时间,因为 Java EE 容器不知道 Cobertura 类.
我尝试将 Maven 调用 clean package
添加为 post-build 步骤,但这并没有改变任何东西 - Jenkins 以某种方式保存了在主要步骤中构建的工件并且只部署它,忽略 post-构建步骤中构建的工件。
目前对我有用的是完全禁用 Jenkins 的 "deploy artifacts" 选项,并将其 运行 改为 post-build mvn clean deploy
。但是,您必须添加 -DskipTests=true
,否则您的所有单元和集成测试都将是 运行 第二次。
我有一个问题,Jenkins 将一个经过检测的 jar 文件提升到 nexus 存储库,所以当它在 jBoss 中部署我的应用程序时抛出异常 Caused by: java.lang.NoClassDefFoundError: net/sourceforge/cobertura/coveragedata/TouchCollector
at com.premierinc.its.pfgpgrouper.service.algorithms.AbstractPopulationGrouper.__cobertura_init
詹金斯行家配置: 版本是 mvn-3.2.3 清理安装站点
我的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.myapp.its</groupId>
<artifactId>myapp</artifactId>
<version>15.2.2.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MyApp</name>
<description>
MY API.
</description>
<scm>
<connection>scm:git:ssh://git@code/pfpg/my-app.git</connection>
<developerConnection>scm:git:ssh://git@code/pfgp/my-app.git</developerConnection>
<tag>HEAD</tag>
</scm>
<distributionManagement>
<repository>
<id>code-artifacts</id>
<url>
http://code/artifacts/content/repositories/releases
</url>
</repository>
<snapshotRepository>
<id>code-artifacts</id>
<url>
http://code/artifacts/content/repositories/snapshots
</url>
</snapshotRepository>
</distributionManagement>
<properties>
<spring.version>4.0.3.RELEASE</spring.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<oracle.version>11.2.0.2.0</oracle.version>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
<configuration>
<argLine>-Xms512m -Xmx512m</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<formats>
<format>xml</format>
<format>html</format>
</formats>
</configuration>
<executions>
<execution>
<phase>site</phase>
<goals>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-jgitflow-plugin</artifactId>
<version>1.0-alpha21.1</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<pushFeatures>true</pushFeatures>
<pushHotfixes>true</pushHotfixes>
<pushReleases>true</pushReleases>
<noReleaseBuild>true</noReleaseBuild>
<noFeatureBuild>true</noFeatureBuild>
<noHotfixBuild>true</noHotfixBuild>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>myFile</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<schemaDirectory>src/main/resources/schema</schemaDirectory>
<outputDirectory>src/main/java/</outputDirectory>
<extension>true</extension>
<arguments>
-no-header -cp collection-setter-injector.jar
-Xcollection-setter-injector
</arguments>
<packageName>com.premierinc.its.pfgpgrouper.dto</packageName>
<staleFile>
${project.build.directory}/generated-sources/jaxb/patient/.staleFlag
</staleFile>
<clearOutputDir>false</clearOutputDir>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>net.java.dev.vcc.thirdparty</groupId>
<artifactId>collection-setter-injector</artifactId>
<version>0.5.0-1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.7</version>
</plugin>
<!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.1</version> </plugin> -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.17</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.13</version>
<configuration>
<configLocation>src/code-analysis/checkstyle.xml</configLocation>
</configuration>
</plugin>
</plugins>
</reporting>
<dependencies>
<!-- DB Driver -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6g</artifactId>
<version>${oracle.version}</version>
</dependency>
<!-- SPRING -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-mock</artifactId>
<version>2.0.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>5.14.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.10</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>
他们在最新版本中修复了 cobertura 的问题,请参阅此 link。
我运行遇到了同样的问题; Maven 3.2.3,cobertura-maven-plugin 2.7,詹金斯 1.608。这似乎是 Jenkins 问题而不是 cobertura 问题。
我的詹金斯工作运行主要构建步骤的 Maven 目标clean verify site:site
。
Jenkins 然后将 verify
期间生成的工件部署到 maven 存储库,但是,jar 中的 类 全部由 Cobertura 检测,导致 NoClassDefFoundErrors
在 运行时间,因为 Java EE 容器不知道 Cobertura 类.
我尝试将 Maven 调用 clean package
添加为 post-build 步骤,但这并没有改变任何东西 - Jenkins 以某种方式保存了在主要步骤中构建的工件并且只部署它,忽略 post-构建步骤中构建的工件。
目前对我有用的是完全禁用 Jenkins 的 "deploy artifacts" 选项,并将其 运行 改为 post-build mvn clean deploy
。但是,您必须添加 -DskipTests=true
,否则您的所有单元和集成测试都将是 运行 第二次。