# Git Forensics long runtime for first build on new branches

**URL:** <https://community.jenkins.io/t/git-forensics-long-runtime-for-first-build-on-new-branches/28959>\
**Category:** Ask a question\
**Created:** [March 27, 2025, 10:50am UTC](https://community.jenkins.io/t/git-forensics-long-runtime-for-first-build-on-new-branches/28959 "2025-03-27T10:50:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![allenjb](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@allenjb](https://community.jenkins.io/u/allenjb)\
**Post date:** [March 27, 2025, 10:50am UTC](https://community.jenkins.io/t/git-forensics-long-runtime-for-first-build-on-new-branches/28959/1 "2025-03-27T10:50:55Z")

</div>

For each new branch / PR, the mineRepository step for the first build is taking ~10 minutes. I can only assume it’s scanning an excessive amount of the commit history. Subsequent builds for additional commits on the same branch/job take seconds at most.

Is this expected behavior, or is something not right/optimal with my setup? Can it not use a cache / data from the controller build (reference job) to only require scanning of new commits in the branch?

Project uses a GitHub sources multibranch pipeline with Jenkinsfile:

```auto
    stages {
        stage('Prepare') {
            steps {
                discoverGitReferenceBuild([
                    referenceJob: "project/master",
                    targetBranch: "master",
                    latestBuildIfNotFound: true,
                ])
                mineRepository()
                gitDiffStat()

```

Console output, for first build on new branch with single new commit compared to controller:

```auto
[Pipeline] discoverGitReferenceBuild
[ReferenceFinder] Configured reference job: 'project/master'
[ReferenceFinder] -> detected 200 commits in current branch (last one: '4ce6a6e')
[ReferenceFinder] -> adding 1 commits from build '#774' of reference job (last one: '7d40491')
[ReferenceFinder] -> found a matching commit in current branch and target branch: '7d40491'
[ReferenceFinder] -> found build '#774' in reference job with matching commits
[ReferenceFinder] Found reference build '#774' for target branch
[ReferenceFinder] -> Build '#774' has a result SUCCESS
[Pipeline] mineRepository
The recommended git tool is: NONE
using credential 03a37a5d-afa4-4d31-b730-b3a7c16e5b10
 > git rev-parse HEAD^{commit} # timeout=10
The recommended git tool is: NONE
using credential 03a37a5d-afa4-4d31-b730-b3a7c16e5b10
[Forensics] Creating SCM miner to obtain statistics for affected repository files
[Forensics] -> checking SCM 'git git@github.com:Org/project.git'
[Forensics] -> Git miner successfully created in working tree '/var/lib/jenkins/workspace/branch_name'
[Forensics] Analyzing the commit log of the Git repository '/var/lib/jenkins/workspace/branch_name'
[Forensics] Found 9906 commits
[Forensics] -> Created report in 643 seconds
[Forensics] -> 9636 commits with differences analyzed
[Forensics] -> 601696 MODIFY commit diff items
[Forensics] -> 15607 RENAME commit diff items
[Forensics] -> 238256 DELETE commit diff items
[Forensics] -> 41412751 lines added
[Forensics] -> 37691214 lines deleted
[Pipeline] gitDiffStat

```

Jenkins setup: (Single server)  
Jenkins 2.492.2  
Forensics API Plugin 3.1.0  
Git Forensics Plugin 3.2.0
