1

I am working on the esp-idf as submodule for my development and I have also integrated Jenkins for the same. It is running perfectly without shallow clone feature added over Jenkins. But, when I tried to clone submodule with shallow clone with depth 1, 5 to 10 it is throwing same error as below,

Cloning into 'platform/esp32'... fatal: reference is not a tree: 286202caa31b61c2182209f37f8069a0b60fb942 Unable to checkout '286202caa31b61c2182209f37f8069a0b60fb942' in submodule path 'SDK/platform/esp32' Failed to recurse into submodule path 'SDK'

However, it is working fine with git commands and without Jenkins.

Any help would be benefits to me.

My Jenkins setup as shown below,

enter image description here

  • 1
    It's pretty clear from your results that you cannot combine submodules and shallow clones in your Jenkins version, and that this is not a Git bug since it works fine in command-line Git. I'll leave it to those much more familiar with Jenkins to tell you what if anything there is to do about it in Jenkins (other than of course not trying to combine shallow clones and submodules). – torek Jan 13 '22 at 09:53

1 Answers1

1

This was also reported in Jenkins issue 60204 for git-scm plugin.
Make sure you have the latest version for that plugin.

Try and cleanup the Jenkins workspace associated with the job (with the help of the WS cleanup plugin)

As noted in JENKINS 63581:

The job definition you uploaded as config.xml includes the "clean before checkout" behavior but does not include the "wipe workspace" behavior.

The "clean before checkout" behavior retains the existing git repository (the .git directory) but removes untracked files.
It does that with the git clean -xfd command.

If the workspace had been previously populated with repository content, the "clean before checkout" does not remove that previously created content.

The git plugin tries to reduce data transfer by retaining the git repository across multiple builds in the same workspace.
You would need to add "Wipe workspace" to assure that the two workspaces have the same content.

If wipe workspace still shows a difference, then it is likely that there is a difference due to the two versions of command line git being used.

The OP Bhargav Lalaji adds in the comments:

I was checking the git command line on the different system and Jenkins was setup on other system.
After check the git versions both of them have different version.

After upgrade the git version from 2.7.4 to 2.34.1, I am able to checkout submodule with shallow clone with Jenkins

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I have tried to use the latest version of git plug-in, "clean before checkout" and "wipe out repository and force clone" all the options. But in all cases same errors occurs. also as you have mentioned the issue 60204 which is marked as won't fix. – Bhargav Lalaji Jan 14 '22 at 05:35
  • > "it is working fine with git commands and without Jenkins." Can you check if this is using the same Git version as the one used by Jenkins on its main controller server? And can you double-check if this work on a different machine than your workstation, to make sure 286202caa31b61c2182209f37f8069a0b60fb942 was actually pushed to the remote repository of the submodule SDK/platform/esp32? – VonC Jan 14 '22 at 06:39
  • I was checking the git command line on the different system and Jenkins was setup on other system. After check the git versions both of them have different version. After upgrade the git version from 2.7.4 to 2.34.1 , I am able to checkout submodule with shallow clone with Jenkins. @Vonc , thanks for your help. – Bhargav Lalaji Jan 15 '22 at 04:58
  • @BhargavLalaji Thank you for the feedback. Good catch. I have included your comment in the answer for more visibility. – VonC Jan 15 '22 at 20:51