skip to Main Content

I set up a jenkins on aws ecs (using official jenkins docker image) with agents also working in aws ecs and it’s workigng great.
But when I tried to edit a pipeline to used git and pull a script from a github repository it didnt worked

I’m facing an error 128.

The credentials to join github are correct (I tested on https and SSH). But each time it fail with and error 128.

Started by user user-admin
Checking out git https://github.com/project/project-jenkins.git/ into /var/jenkins_home/workspace/trigger-gitlab-deploy@script/42b7b18e861df0b75ee35873b425e5868cf680207c5d0c9a900960ef6bc6fcb9 to read jobs/trigger-gitlab-deploy/Jenkinsfile
Selected Git installation does not exist. Using Default
The recommended git tool is: NONE
using credential toto-ci-github
Cloning the remote Git repository
Cloning repository https://github.com/totonow/toto-jenkins.git/
 > git init /var/jenkins_home/workspace/trigger-gitlab-deploy@script/42b7b18e861df0b75ee35873b425e5868cf680207c5d0c9a900960ef6bc6fcb9 # timeout=10
Fetching upstream changes from https://github.com/totonow/toto-jenkins.git/
 > git --version # timeout=10
 > git --version # 'git version 2.30.2'
using GIT_ASKPASS to set credentials Credentials use to pull jenkinsfile from github
 > git fetch --tags --force --progress -- https://github.com/totonow/toto-jenkins.git/ +refs/heads/*:refs/remotes/origin/* # timeout=10
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --force --progress -- https://github.com/totonow/toto-jenkins.git/ +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: fatal: detected dubious ownership in repository at '/var/jenkins_home/workspace/trigger-gitlab-deploy@script/42b7b18e861df0b75ee35873b425e5868cf680207c5d0c9a900960ef6bc6fcb9'
To add an exception for this directory, call:

    git config --global --add safe.directory /var/jenkins_home/workspace/trigger-gitlab-deploy@script/42b7b18e861df0b75ee35873b425e5868cf680207c5d0c9a900960ef6bc6fcb9

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2842)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2185)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:635)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:871)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1222)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1305)
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:129)
    at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:159)
    at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:70)
    at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:312)
    at hudson.model.ResourceController.execute(ResourceController.java:101)
    at hudson.model.Executor.run(Executor.java:442)
ERROR: Error cloning remote repo 'origin'
ERROR: Maximum checkout retry attempts reached, aborting
Finished: FAILURE

I tried the option git config --global --add safe.directory '*' but I still have a 128 error.

The strange part is, when I connect to the container in ecs (using ecs exec) and when i tried to clone the repository, in the workspace directory of the container, it works.

So that’s not a network issue.

I noticed that when I run a pipeline from Jenkins, it create in the workspace directory of the jenkins master a directory, with the name of the jenkins jobstrigger-gitlab-deploy@script (the name is "trigger-gitlab-deploy" in jenkins).

With inside another directory (probably an ID ?) 42b7b18e861df0b75ee35873b425e5868cf680207c5d0c9a900960ef6bc6fcb9, where there is inside a .git folder, but where the "config" file is not configured.

So it seems that Jenkins tried to clone the repository but failed, however I don’t know why because git clone commands works directly from the container with the same credentials.

Is somebody has an idea of what could be the issue ?
I tried to update the log level of jenkins but it didnt help me.

I already set up this kind of jenkins with on demand agents but it was on a kubernetes cluster and it was working ..

2

Answers


  1. Chosen as BEST ANSWER

    Here the error after apply the solution : git submodule update failed with 'fatal: detected dubious ownership in repository at'

    Started by user admin
    Checking out git [email protected]:project/project-jenkins.git into /var/jenkins_home/workspace/trigger-gitlab-deploy@script/80a5dd42e7203e5973ddaf44633c03f8680ca8ea7fc65ddc43c4b66e8d1c429f to read jobs/trigger-gitlab-deploy/Jenkinsfile
    Selected Git installation does not exist. Using Default
    The recommended git tool is: NONE
    using credential jenkins-user
     > /usr/bin/git rev-parse --resolve-git-dir /var/jenkins_home/workspace/trigger-gitlab-deploy@script/80a5dd42e7203e5973ddaf44633c03f8680ca8ea7fc65ddc43c4b66e8d1c429f/.git # timeout=10
    Fetching changes from the remote Git repository
     > /usr/bin/git config remote.origin.url [email protected]:project/project-jenkins.git # timeout=10
    ERROR: Error fetching remote repo 'origin'
    hudson.plugins.git.GitException: Failed to fetch from [email protected]:project/project-jenkins.git
        at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:999)
        at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1241)
        at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1305)
        at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:129)
        at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:159)
        at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:70)
        at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:312)
        at hudson.model.ResourceController.execute(ResourceController.java:101)
        at hudson.model.Executor.run(Executor.java:442)
    Caused by: hudson.plugins.git.GitException: Command "/usr/bin/git config remote.origin.url [email protected]:project/project-jenkins.git" returned status code 128:
    stdout: 
    stderr: fatal: not in a git directory
    
        at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2842)
        at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2762)
        at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2757)
        at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:2051)
        at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:2063)
        at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.setRemoteUrl(CliGitAPIImpl.java:1662)
        at hudson.plugins.git.GitAPI.setRemoteUrl(GitAPI.java:180)
        at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:987)
        ... 8 more
    ERROR: Error fetching remote repo 'origin'
    ERROR: Maximum checkout retry attempts reached, aborting
    Finished: FAILURE
    

    Jenkins is started with the jenkins user, jenkins_home is jenkins:jenkins however Jenkins clone with git in workspace as root:root ..


  2. The root cause of the error is this message:

    stderr: fatal: detected dubious ownership in repository at ‘/var/jenkins_home/workspace/trigger-gitlab-deploy@script/42b7b18e861df0b75ee35873b425e5868cf680207c5d0c9a900960ef6bc6fcb9′
    To add an exception for this directory, call:
    ”’

    See git submodule update failed with 'fatal: detected dubious ownership in repository at' for solutions for that condition.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search