Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-59497

Git clone in pipeline ignoring reference repo

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Cannot Reproduce
    • Component/s: git-plugin
    • Labels:
    • Environment:
      Jenkins 2.176.1
      Git Plugin 3.9.1
    • Similar Issues:

      Description

      On a freestyle project, everything works fine, but on a declarative pipeline I cannot make the reference repository to work

      Example of how we check out in the pipeline:

       

      checkout(
          [
              $class : 'GitSCM',
              branches : [[ name: "${branch}" ]],
              doGenerateSubmoduleConfigurations: false,
              extensions : [
                  [$class : 'RelativeTargetDirectory',
                   relativeTargetDir: targetDir
                  ],
                  [$class : 'CloneOption',
                   reference: '/somefolder/repo'
                  ]
              ],
              userRemoteConfigs : [[
                  url : ssh://blahblah/some.git,
                  credentialsId: ourCredentialsId
              ]]
          ]
      )
      

       

       

      and the output looks like this:

      [Pipeline] git
      Fetching changes from the remote Git repository
       > git rev-parse --is-inside-work-tree # timeout=10
       > git config remote.origin.url ssh://blahblah/some.git # timeout=10
      Fetching upstream changes from ssh://blahblah/some.git
       > git --version # timeout=10
      using GIT_SSH to set credentials Bitb-ssh-read
       > git fetch --tags --progress ssh://blahblah/some.git +refs/heads/*:refs/remotes/origin/*
      Checking out Revision 5eaf094e260b45a236792d8fd43f7d991bf9bbe0 (refs/remotes/origin/master)
       > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
       > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
       > git config core.sparsecheckout # timeout=10
       > git checkout -f 5eaf094e260b45a236792d8fd43f7d991bf9bbe0
      Commit message: "look mommy no hands"
      First time build. Skipping changelog.
      

      It is not even trying to use the reference, as there is no line like

      Using reference repository: /somefolder/repo
      

       

       

       

        Attachments

          Activity

          Hide
          markewaite Mark Waite added a comment -

          I can't duplicate the problem you're describing.

          I've created a test job that confirms the reference repository is honored by both command line git and JGit. I've confirmed that for the command line git implementation, the diagnostic message is consistently printed and the reference repository is consistently used.

          The reference repository path may be specified incorrectly in the checkout step. The reference repository may be missing on the agent where the workspace is being created.

          Show
          markewaite Mark Waite added a comment - I can't duplicate the problem you're describing. I've created a test job that confirms the reference repository is honored by both command line git and JGit. I've confirmed that for the command line git implementation, the diagnostic message is consistently printed and the reference repository is consistently used. The reference repository path may be specified incorrectly in the checkout step. The reference repository may be missing on the agent where the workspace is being created.
          Hide
          markewaite Mark Waite added a comment -

          The RelativeTargetDir extension is not recommended for use in Pipeline. The dir() and ws() directives are native Pipeline directives that are better suited for use than the git plugin specific extension RelativeTargetDir. That does not affect this case, but is good advice for your implementation. My test cases used both dir() and RelativeTargetDir successfully.

          Show
          markewaite Mark Waite added a comment - The RelativeTargetDir extension is not recommended for use in Pipeline. The dir() and ws() directives are native Pipeline directives that are better suited for use than the git plugin specific extension RelativeTargetDir . That does not affect this case, but is good advice for your implementation. My test cases used both dir() and RelativeTargetDir successfully.
          Hide
          vince82 Vincenzo Melandri added a comment -

          I made a brand new job that just checkouts the repo and cats a file to isolate it from interference and I found out that it works, but there is still a massive difference:
          A test freestyle jobs checks out the repo in under 5 seconds, while the job defined with pipeline takes upward of 40s, which is still faster than a non-referenced checkout, which takes about 400 seconds.. 

          Show
          vince82 Vincenzo Melandri added a comment - I made a brand new job that just checkouts the repo and cats a file to isolate it from interference and I found out that it works, but there is still a massive difference: A test freestyle jobs checks out the repo in under 5 seconds, while the job defined with pipeline takes upward of 40s, which is still faster than a non-referenced checkout, which takes about 400 seconds.. 
          Hide
          markewaite Mark Waite added a comment -

          Vincenzo Melandri that seems like a separate bug report is needed. Pipeline has some overhead compared to Freestyle but that much overhead is beyond what I expected.

          Show
          markewaite Mark Waite added a comment - Vincenzo Melandri that seems like a separate bug report is needed. Pipeline has some overhead compared to Freestyle but that much overhead is beyond what I expected.

            People

            • Assignee:
              Unassigned
              Reporter:
              vince82 Vincenzo Melandri
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: