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

Multibranch pipeline 'checkout scm' does not handle Git submodules

    XMLWordPrintable

Details

    Description

      When using a Multibranch Pipeline job type, the Jenkinsfile in the SCM repository branch being built contains the statement checkout scm. But if the Git repository contains submodules, they are not initialized or updated in the Jenkins build workspace.

      Typically submodule initialization/updating is automatically handled by the Git SCM for Jenkins Freestyle jobs.

      Workaround

      You can call the git executable manually from the Jenkinsfile pipeline DSL, like this:

              checkout scm
              bat 'git submodule update --init'     // or sh
      

      Attachments

        Issue Links

          Activity

            jglick Jesse Glick added a comment -

            I think you would need to configure the SCM source to include the submodule extension.

            jglick Jesse Glick added a comment - I think you would need to configure the SCM source to include the submodule extension.

            This workaround does not always work. The scm credentials used to check out the repository are not available in the sh line so you can get an access denied.

            Is there any way to execute the submodule command in the same context as the `checkout scm` is being run?

            stefanfreyr Stefan Freyr Stefansson added a comment - This workaround does not always work. The scm credentials used to check out the repository are not available in the sh line so you can get an access denied. Is there any way to execute the submodule command in the same context as the `checkout scm` is being run?
            uhp UHP added a comment -

            There is a solution for that using the approaches described in https://support.cloudbees.com/hc/en-us/articles/226122247-How-to-Customize-Checkout-for-Pipeline-Multibranch

            Problem for us is that calling

            checkout([
                    $class: 'GitSCM',....])

            seems to create the "impression" that another repo is used. We get the error
            None or multiple repos
            when we call "bitbucketStatusNotify(...)"

             

            uhp UHP added a comment - There is a solution for that using the approaches described in https://support.cloudbees.com/hc/en-us/articles/226122247-How-to-Customize-Checkout-for-Pipeline-Multibranch Problem for us is that calling checkout([         $class: 'GitSCM',....]) seems to create the "impression" that another repo is used. We get the error None or multiple repos when we call "bitbucketStatusNotify(...)"  
            smithj james smith added a comment -

            I ran into this problem today, submodules not being checked out, and the problem in my case was that I added the submodules to use ssh, but the multibranch pipeline uses https to do the git checkout. Once I updated my .gitmodules to use https urls it worked fine.

            smithj james smith added a comment - I ran into this problem today, submodules not being checked out, and the problem in my case was that I added the submodules to use ssh, but the multibranch pipeline uses https to do the git checkout. Once I updated my .gitmodules to use https urls it worked fine.

            People

              Unassigned Unassigned
              cbennett Colin Bennett
              Votes:
              0 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: