简体   繁体   English

Jenkins / Maven增量构建问题

[英]Jenkins/Maven Incremental Build troubles

I've been tasked with picking up all the maven/jenkins related projects. 我的任务是完成所有与maven / jenkins相关的项目。 Currently whenever a SCM change comes through in jenkins (svn driven), the altered file is rebuilt and everything that depends on it builds and this effect cascades. 目前,只要在jenkins(svn驱动)中发生SCM更改,就会重建已更改的文件,并且依赖于它的所有内容都会构建并且此效果会逐渐增加。 While this is in a sense good, it is not the preferred behavior. 虽然这在某种意义上是好的,但它不是首选的行为。 What is currently desired is that the altered file is built and everything immediately dependent builds without it cascading forward unless the second file is now different. 目前需要的是构建更改的文件并且所有立即依赖的构建都不会向前级联,除非第二个文件现在不同。 The only solution(?) I can still think of is that Jenkins/Maven is not actually aware of the relationship between projects and isn't doing the limited cascade because it doesn't no where to trigger a build. 我仍然可以想到的唯一解决方案(?)是Jenkins / Maven实际上并没有意识到项目之间的关系,也没有做有限的级联,因为它不会触发构建。

Within Jenkins, disabling the "Build whenever a snapshot dependency is built" and instead using in the advanced build options using "incremental build". 在Jenkins中,禁用“构建快照依赖项时构建”,而是使用“增量构建”在高级构建选项中使用。 Polling scm is also enabled. 轮询scm也已启用。 Jenkins no longer has on the project page any explicit knowledge of up/downstream projects. Jenkins在项目页面上不再具有上/下游项目的明确知识。

When a SCM change comes through, there is no cascade effect to the immediately dependent modules. 当SCM更改通过时,对直接相关模块没有级联效果。 Jenkins was not taking care of the incremental step so a incremental-build-plugin was used, no different behavior happened. Jenkins没有处理增量步骤,因此使用了增量构建插件,没有发生任何不同的行为。

In a sandbox environment meant to simulate what our actual project is trying to accomplish. 在沙盒环境中,旨在模拟我们的实际项目正在尝试完成的任务。

Sandbox setup 沙箱设置

 |Trunk
 --|Project_C
 | -Pom.xml
 | -src
 --|Project_B
 | -pom.xml
 | -src
 --|Project_A
 | -pom.xml
 | -src

Project A depends on Project B. Project B depends on Project C. 项目A取决于项目B.项目B取决于项目C.

When a change is made (+ SCM'd) in the src code of Project C that would effect the behavior of Project B Jenkins only rebuilds Project_C. 当项目C的src代码中的更改(+ SCM'd)将影响项目B的行为时,Jenkins仅重建Project_C。

pom.xml for Project C Project C的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>project</groupId>
    <artifactId>c</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
    <name>c</name>

    <build>
        <plugins>
            <plugin>
          <groupId>org.jvnet.maven.incrementalbuild</groupId>
              <artifactId>incremental-build-plugin</artifactId>
          <version>1.3</version>
              <executions>
                <execution>
                  <goals>
                    <goal>incremental-build</goal>
                  </goals>
                </execution>
              </executions>
            </plugin>
        </plugins>
    </build>
</project>

pom.xml for Project B 项目B的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>project</groupId>
    <artifactId>b</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
    <name>b</name>
    <build>
        <plugins>
      <plugin>
              <groupId>org.jvnet.maven.incrementalbuild</groupId>
              <artifactId>incremental-build-plugin</artifactId>
              <version>1.3</version>
              <executions>
                <execution>
                  <goals>
                    <goal>incremental-build</goal>
                  </goals>
                </execution>
              </executions>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>project</groupId>
            <artifactId>c</artifactId>
            <version>1.0</version>
            <type>jar</type>
        </dependency>
    </dependencies>
</project>

Side Note: Does anyone greatly understand the interaction between the "incremental build" option with the "build whenever a snapshot dependency is built" option? 附注:有没有人非常理解“增量构建”选项与“构建快照依赖关系时构建”选项之间的交互?

它不是jenkins插件,它是底层maven,无法检测到这种变化, 我已经公开请求它已经看到:MNG-5523

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM