Jenkins Build Gets Stuck When Pulling from Git Repository

I’m having an issue with my Jenkins CI setup where the build process completely hangs during the Git fetch operation. The build gets stuck right after this message appears:

Retrieving updates from remote Git repository

Pulling latest changes from [email protected]:myuser/MyProject.git

[workspace] $ "C:\Program Files\Git\bin\git.exe" fetch -t [email protected]:myuser/MyProject.git +refs/heads/*:refs/remotes/origin/*

The build was triggered by an anonymous user and it just sits there indefinitely without any progress or error messages. I’ve waited for over an hour but nothing happens.

Has anyone experienced similar freezing issues with Git operations in Jenkins? What could be causing this hang and how can I resolve it?

Sounds like an SSH authentication timeout - I’ve hit this before. When Jenkins hangs on Git fetch without any error messages, it’s usually stuck waiting for SSH key auth that never happens. Check if Jenkins can actually access the SSH private key you’ve set up for the repo. In my case, the key was there but had wrong file permissions, so Jenkins couldn’t read it. Also make sure the SSH key is added to your GitHub repo’s deploy keys, or that your Jenkins user has SSH agent configured properly. Could also be network issues - some corporate firewalls block SSH on port 22, which causes these silent hangs.

same issue for me b4! had to switch to https in jenkins settings - the ssh key thing can get finicky sometimes. also look at your jenkins ram, low memory can cause hangs too. hope this helps!

This happens when Jenkins can’t access Git properly - usually missing credentials or network issues. Had the same problem last year. Turned out the Jenkins service account was missing the SSH key in its .ssh directory. Check your Jenkins system config under Global Tool Configuration and make sure the Git executable path is right. Also try turning on verbose logging - go to Manage Jenkins > System Log and add a new logger for hudson.plugins.git with DEBUG level. You’ll see exactly where it’s failing. If you’re still stuck, switch to HTTPS with a personal access token instead of SSH. Way more reliable for automated stuff.

kill the hanging build first, then check if your git repo URL is still valid - repos sometimes get moved or renamed and jenkins doesnt handle that well. also try disabling strict host key checking in jenkins git settings. that’s what fixed it for me when it hung.