Jenkins Multibranch Pipeline job fails to checkout Git repository - solution

Posted on December 3rd, 2018 at 18:00 PM

We had a Multibranch Pipeline job that was running fine and then started to fail at the ‘Scan Multibranch Pipeline’. The scan reported an error with lightweight checkout of the Jenkinsfile and failed the scan at a specific branch. Excluding that branch from the scan confirmed the offending branch. Following further commits to the branch the scan reported a more severe failure with ‘git fetch’. The solution was to delete the job entry in the Jenkins git cache here /var/lib/jenkins/cache. Identify the cached repo by finding relevant branches:

root@jenkins:/var/lib/jenkins/caches# find -name BRANCH-11*

The coup des grace is the deletion of the identified repo:

rm -rf git-1234567890abcdef1234567890abcdef/

It was unclear why the cached repo had become corrupted though initial symptoms did coincide with the server running out of space. All other jobs continued to run successfully.