【问题标题】:JaCoCo Memory Allocation after Job is terminatedJob 终止后的 JaCoCo 内存分配
【发布时间】:2017-03-14 13:03:02
【问题描述】:

上周我在与 Jenkins 合作时发现了一个奇怪的时刻。 在我的多模块项目中,我在 Jenkins 中使用 Jacoco 测试覆盖率Jacoco-plugin

我在我的 Jenkins 中开始了一些工作,当涉及到 测试阶段时,将创建 Jacoco 进程,并且在作业执行后,该进程将被关闭。但是当作业在测试阶段卡住时,唯一的办法就是终止作业。但在这种情况下,Jacoco 进程不会关闭,即使在 Jenkins 重新启动后也是如此。 唯一的方法是杀死进程。

我有一个 Jenkins 在我的物理机器上运行,另一个在 docker 上运行。两种情况都会出现问题。

这是我在父 pom.xml 中的 Jacoco 配置,但我确信这不是重点。:

<plugins>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.7.7.201606060606</version>
            <configuration>
                <excludes>
                    <exclude>**/*Builder.class</exclude>
                </excludes>
            </configuration>
            <executions>
                <execution>
                    <id>default-prepare-agent</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
                <execution>
                    <id>default-prepare-agent-integration</id>
                    <goals>
                        <goal>prepare-agent-integration</goal>
                    </goals>
                </execution>
                <execution>
                    <id>default-report</id>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
                <execution>
                    <id>default-report-integration</id>
                    <goals>
                        <goal>report-integration</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

有没有人遇到过同样的问题,或者有一些提示或猜测?

【问题讨论】:

    标签: maven jenkins jacoco jacoco-maven-plugin


    【解决方案1】:

    我还没有找到这个问题的具体解决方案,但我已经建立了一个小的解决方法。也许它对某人有用。

    关键是要创建一个每小时运行一个脚本的作业。该脚本正在检查是否有一些运行时间超过 3600 秒的 jacoco 进程并杀死它们。

    脚本:

    #!/bin/bash
    
    PROCESS_NAME=jacoco
    MAX_TIME=3600
    
    echo "Searching for  $PROCESS_NAME processes running for more than $MAX_TIME seconds"
    
    pgrep -f $PROCESS_NAME | while read pid 
    do
        running_time=$(ps -feo "etimes=" $pid | sed -e 's/ //g')
        if [ $running_time -gt $MAX_TIME ]
        then
            echo "killing the process with $pid"
            kill $pid
        fi       
    done
    

    【讨论】:

      猜你喜欢
      • 2011-10-07
      • 1970-01-01
      • 1970-01-01
      • 2018-02-02
      • 2020-07-20
      • 1970-01-01
      • 2012-04-28
      • 1970-01-01
      相关资源
      最近更新 更多