
[Solution] Git Clone Error: java.io.IOException: error=2, No such file or directory
- Last Updated on: February 23, 2019
- By: scriptcrunch
Issue:
In Jenkins, when I am trying to clone a git repository I am getting the following error.
Attempting to resolve master from remote references... --version # timeout=10 ls-remote https://github.com/repo.git # timeout=10 java.io.IOException: error=2, No such file or directory org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: WorkflowScript: Loading libraries failed
Solution:
This is a common issue which occurs when you are configuring a new Jenkins or configuring it for the first time.
Make sure you have the following settings already configured. It could be because of these reasons as well.
- Git should be installed on the slave where you are trying to clone the repo.
- Your git repo should be accessible from the slave machine.
- You should have Git Plugin installed on Jenkins
If the above prerequisites are met and you are getting the error, then is a Jenkins git configuration issue. You need to configure git on Jenkins.
Jenkins Git Configuration
Step 1: Login to your slave machine and get the git executable path using the following command.
which git
You should see something as shown below.
[jenkins@jenkins-slave ~]$ which git /bin/git [jenkins@jenkins-slave ~]$
/bin/git
is the git executable location
Step 2: Go to Manage Jenkins
–> Global Tool Configuration

Step 3: Add the git executable path you got in Step 1 as shown below.

Thats it! now if you build your Jenkins jobs, you should not see the error! Please comment below if you think there are more edge cases in this type of errors.
Other Interesting Blogs

CKA Exam Study Guide: Certified Kubernetes Administrator
Passing the cloud-native Certified Kubernetes Administrator (CKA) exam is not a cakewalk. To pass the CKA exam, you should have enough hands-on

Linux Foundation Coupon for 2023
Hi Techies, I wanted to let you know about a pretty sweet deal with the Linux Foundation Coupon that is running now.

[35% OFF] Linux Foundation LFCA, LFCS & LFCT Exam Voucher Codes
Linux Foundation has announced up to a $284 discount on its Linux certification programs Linux Foundation Certified IT Associate (LFCA) and Linux