Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins not able to fetch code from remote git

Tags:

git

jenkins

My jenkins build is suddenly not working now.The error is as follows:-

Fetching changes from the remote Git repository  > git config remote.origin.url <url> # timeout=10 ERROR: Error fetching remote repo 'origin' hudson.plugins.git.GitException: Failed to fetch from <url>     at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:735)     at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:983)     at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1016)     at hudson.scm.SCM.checkout(SCM.java:484)     at hudson.model.AbstractProject.checkout(AbstractProject.java:1270)     at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:622)     at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)     at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:528)     at hudson.model.Run.execute(Run.java:1759)     at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:529)     at hudson.model.ResourceController.execute(ResourceController.java:89)     at hudson.model.Executor.run(Executor.java:240) Caused by: hudson.plugins.git.GitException: Command "git config remote.origin.url <url> returned status code 4: stdout:  stderr: error: failed to write new configuration file .git/config.lock 

I am not able to figure out the root cause. I have checked the permission and ownership for jenkins home folder which is /var/lib/jenkins:- drwxrwxrwx 17 jenkins jenkins 4096 Jun 25 04:30 jenkins

Permission and ownership of .git folder inside workspace folder of jenkins is:- drwxrwxrwx 8 jenkins jenkins 4096 Jun 30 21:51 .git

Please guide me fix the problem.

like image 758
nishat Avatar asked Jun 30 '15 04:06

nishat


People also ask

Can Jenkins pull code from Git?

With the help of the Git plugin Jenkins can easily pull source code from any Git repository that the Jenkins build node can access. The GitHub plugin extends upon that integration further by providing improved bi-directional integration with GitHub.

How do I add a remote Git repository to Jenkins?

Follow these steps: Step 1 Go to Manage Jenkins -> Manage Plugin. Step 2 Search Github Plugin in the Available tab then click on Download now and install after the restart. Step 3 Under Source Code Management tab, select Git and then set the Repository URL to point to your GitHub Repository.

How do I access Git in Jenkins?

http://localhost:8080/jenkins/restart Select 'Freestyle project' as the item type. Click the Ok button. In the next screen, if you browse to the Source code Management section, you will now see 'Git' as an option.

Can we connect Git with Jenkins yes or no?

NOTE: If the Git option does not appear, try re-installing the plugins, followed by a restart and a re-login into your Jenkins dashboard. You will now be able to see the Git option as mentioned above. Step 5) Enter the Git repository URL to pull the code from GitHub.


1 Answers

I was seeing the same issue, but disk space and VM memory were not the problem. What fixed it for me was making the job re-clone on build:

  1. Go to the job's "Configure" page
  2. Under Source Code Management → Git → Additional Behaviors, add a behavior "Wipe out repository & force clone"
  3. Save
  4. Build
like image 79
JohnnyRico Avatar answered Sep 27 '22 23:09

JohnnyRico