gitjenkinsesp-idfshallow-clone

git shallow is not working for submodules over jenkins?


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


Solution

  • 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