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

Pipeline SCM checkout fails to find Jenkinsfile in submodule with lightweight checkout

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Trivial Trivial
    • git-plugin
    • None
    • Jenkins Version 2.516.2

      Git Plugin Version: [5.7.0](https://plugins.jenkins.io/git)

      Pipeline: Groovy Version: 4183.v94b_6fd39da_c1

      Service(s)
      plugins.jenkins.io

      Summary
      Problem Summary

      When configuring a Pipeline job to use "Pipeline script from SCM" with a Git repository that contains the Jenkinsfile in a Git submodule, the build fails immediately with an error stating it cannot find the Jenkinsfile. This happens even though the "Recursively update submodules" behavior is added in the job configuration.

      The error observed is:

      text
      ERROR: Unable to find .ci/Jenkinsfile from git https://code.example.com/group/project.git
      Finished: FAILURE
      However, manually cloning the same repository and running git submodule update --init --recursive on the Jenkins server works perfectly and the file is present in the expected path (.ci/Jenkinsfile).

      This suggests that Jenkins attempts to locate and parse the Jenkinsfile before the submodule update process has fully completed or initialized successfully.

      Reproduction steps
      1.Create a Git repository (main-repo) for a project.

      2.Create another Git repository (ci-files) to host the Jenkinsfile.

      3.In main-repo, add ci-files as a Git submodule in the .ci directory.
      git submodule add <url-of-ci-files-repo> .ci

      4.In the Jenkins web interface, create a new Pipeline job.

      5.Configure the Pipeline section:

      Definition: Pipeline script from SCM
      SCM: Git
      Repository URL:
      Script Path: .ci/Jenkinsfile
      6.In the Git SCM configuration, under "Additional Behaviours", add "Recursively update submodules". and add "Use credentials from default remote of parent repository"

      7.Save the job and run it.

      Expected Result
      The build should:

      1.Clone the main-repo.

      2.Initialize and update the submodule located at .ci, fetching the contents of the ci-files repository.

      3.Locate the Jenkinsfile within the .ci subdirectory.

      4.Proceed to execute the pipeline defined in that Jenkinsfile.

      Actual Result
      The build fails immediately after the initial clone of the main-repo, before the submodule is fully initialized and populated. The error indicates the Jenkinsfile is not found, implying the submodule update step happens after the initial lookup for the Jenkinsfile or fails silently.

        1. Jenkins Pipeline Git Config.png
          322 kB
          chengli
        2. Additional Behaviours.png
          348 kB
          chengli
        3. Console Output.png
          191 kB
          chengli
        4. Jenkins Version.png
          1.39 MB
          chengli
        5. Git Plugin Version.png
          178 kB
          chengli
        6. JENKINS-76055.tar.gz
          21 kB
          Mark Waite
        7. Jenkins Console.png
          193 kB
          chengli
        8. Script path.png
          384 kB
          chengli
        9. Jenkins 2.524 Console Output.png
          302 kB
          chengli
        10. SuccessDemonstrate.png
          504 kB
          chengli
        11. Lightweight checkout.png
          115 kB
          chengli

            markewaite Mark Waite
            spongebob chengli
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: