5

Hi I am getting this error when I try to build my project in Jenkins.

Started by user jenkins
Building in workspace /var/lib/jenkins/workspace/booking-widget-api
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://xxx@bitbucket.org/yyy/repo-name.git # timeout=10
Fetching upstream changes from https://xxx@bitbucket.org/yyy/repo-name.git
 > git --version # timeout=10
using GIT_ASKPASS to set credentials 
 > git fetch --tags --progress https://xxx@bitbucket.org/yyy/repo-name.git +refs/heads/*:refs/remotes/origin/*
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://xxx@bitbucket.org/yyy/repo-name.git
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:888)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1155)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1186)
    at hudson.scm.SCM.checkout(SCM.java:504)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1208)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
    at hudson.model.Run.execute(Run.java:1794)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress https://xxx@bitbucket.org/yyy/repo-name.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: remote: Counting objects: 8, done.        
remote: Compressing objects:  12% (1/8)           
remote: Compressing objects:  25% (2/8)           
remote: Compressing objects:  37% (3/8)           
remote: Compressing objects:  50% (4/8)           
remote: Compressing objects:  62% (5/8)           
remote: Compressing objects:  75% (6/8)           
remote: Compressing objects:  87% (7/8)           
remote: Compressing objects: 100% (8/8)           
remote: Compressing objects: 100% (8/8), done.        
remote: Total 8 (delta 5), reused 0 (delta 0)        
error: insufficient permission for adding an object to repository database .git/objects
fatal: failed to write object
fatal: unpack-objects failed

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2002)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1721)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:72)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:405)
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:886)
    ... 11 more
ERROR: Error fetching remote repo 'origin'
Finished: FAILURE

First time when I get this error. I just give up for some time (a day). Then I build the project, it worked as normal and build successfully. Now again I am getting this error. Does any body face this kind of issue?

Nic
  • 327
  • 1
  • 18
margherita pizza
  • 6,623
  • 23
  • 84
  • 152
  • 1
    Not enough space on disk might be the reason. Also try to always wipe the workspace and clone a fresh repo every build. – Croolman Feb 05 '19 at 06:52

3 Answers3

6

Stumbled upon this topic while searching for the same solution.

We have this Jenkins multi-branch pipeline which has been there for a long time. One day it started failing with the same errors.

Fetching origin...
Fetching upstream changes from origin
 > git --version # timeout=10
 > git config --get remote.origin.url # timeout=10
using GIT_ASKPASS to set credentials 
 > git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/*
hudson.plugins.git.GitException: Command "git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: Authorized uses only. All activity may be monitored and reported
remote: Counting objects: 82, done.        
remote: Compressing objects:   1% (1/54)           
remote: Compressing objects:   3% (2/54)           
remote: Compressing objects:   5% (3/54)           
remote: Compressing objects:   7% (4/54)           
remote: Compressing objects:   9% (5/54)           
remote: Compressing objects:  11% (6/54)           
remote: Compressing objects:  12% (7/54)           
remote: Compressing objects:  14% (8/54)           
remote: Compressing objects:  16% (9/54)           
remote: Compressing objects:  18% (10/54)           
remote: Compressing objects:  20% (11/54)           
remote: Compressing objects:  22% (12/54)           
remote: Compressing objects:  24% (13/54)           
remote: Compressing objects:  25% (14/54)           
remote: Compressing objects:  27% (15/54)           
remote: Compressing objects:  29% (16/54)           
remote: Compressing objects:  31% (17/54)           
remote: Compressing objects:  33% (18/54)           
remote: Compressing objects:  35% (19/54)           
remote: Compressing objects:  37% (20/54)           
remote: Compressing objects:  38% (21/54)           
remote: Compressing objects:  40% (22/54)           
remote: Compressing objects:  42% (23/54)           
remote: Compressing objects:  44% (24/54)           
remote: Compressing objects:  46% (25/54)           
remote: Compressing objects:  48% (26/54)           
remote: Compressing objects:  50% (27/54)           
remote: Compressing objects:  51% (28/54)           
remote: Compressing objects:  53% (29/54)           
remote: Compressing objects:  55% (30/54)           
remote: Compressing objects:  57% (31/54)           
remote: Compressing objects:  59% (32/54)           
remote: Compressing objects:  61% (33/54)           
remote: Compressing objects:  62% (34/54)           
remote: Compressing objects:  64% (35/54)           
remote: Compressing objects:  66% (36/54)           
remote: Compressing objects:  68% (37/54)           
remote: Compressing objects:  70% (38/54)           
remote: Compressing objects:  72% (39/54)           
remote: Compressing objects:  74% (40/54)           
remote: Compressing objects:  75% (41/54)           
remote: Compressing objects:  77% (42/54)           
remote: Compressing objects:  79% (43/54)           
remote: Compressing objects:  81% (44/54)           
remote: Compressing objects:  83% (45/54)           
remote: Compressing objects:  85% (46/54)           
remote: Compressing objects:  87% (47/54)           
remote: Compressing objects:  88% (48/54)           
remote: Compressing objects:  90% (49/54)           
remote: Compressing objects:  92% (50/54)           
remote: Compressing objects:  94% (51/54)           
remote: Compressing objects:  96% (52/54)           
remote: Compressing objects:  98% (53/54)           
remote: Compressing objects: 100% (54/54)           
remote: Compressing objects: 100% (54/54), done.        
remote: Total 82 (delta 16), reused 0 (delta 0)        
error: insufficient permission for adding an object to repository database .git/objects
fatal: failed to write object
fatal: unpack-objects failed

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2042)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1761)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$400(CliGitAPIImpl.java:72)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:442)
    at jenkins.plugins.git.AbstractGitSCMSource.doRetrieve(AbstractGitSCMSource.java:351)
    at jenkins.plugins.git.AbstractGitSCMSource.retrieve(AbstractGitSCMSource.java:374)
    at jenkins.scm.api.SCMSource.fetch(SCMSource.java:583)
    at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:98)
    at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:293)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)
Finished: FAILURE

My colleague suggested to remove the .git from the Project Repository URL --- it worked!

We still haven't found the reason how it worked, but yeahh it does.

Lester
  • 1,411
  • 1
  • 12
  • 30
0

Based on this error: error: insufficient permission for adding an object to repository database .git/objects
You may want to have a look at: Git Push Error: insufficient permission for adding an object to repository database
Likely want to review some permissions.

0

Reconfigure Jenkins Job

In our case the following helped:

  • Turn off the job configuration for Lightweight checkout

Why it was working all the time with no change on jenkins / bitbucket / jenkins job - no idea.

This feature is described as follows:

If selected, try to obtain the Pipeline script contents directly from the SCM without performing a full checkout. The advantage of this mode is its efficiency; however, you will not get any changelogs or polling based on the SCM. (If you use checkout scm during the build, this will populate the changelog and initialize polling.) Also build parameters will not be substituted into SCM configuration in this mode. Only selected SCM plugins support this mode.

timguy
  • 2,063
  • 2
  • 21
  • 40