This article shows how to fix "failed to connect to repository” Error while setting up Github Jenkins Plugin.
You might get this error when you try to paste a repository URL in the "Source Code Management > Git > Repository URL" section of a new job in Jenkins. The problem may occur when your system cannot locate git installation. You need to make sure you have git installed in your system. A simple way to check in Windows is as shown below:
Once you have verified you have git installed. If you are using Jenkins on a VM or local system, locate the git installation folder. A simple way to get this location is running a PowerShell command.
Once you have the path, you need to set the path to your git executable in Manage Jenkins -> Global Tool Configuration -> Git -> Git Installations -> Path to Git executable.
After this you can paste your repository URL and it will not give any errors: