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

shallowClone is not adding --depth=1 to git clone

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • job-dsl-plugin

      If I use this script to create a job and then run it the console shows that the --depth=1 option is not getting passed to the git clone command line (this is with the latest git plugin 2.4.0)

      job "jenkins-dsl-test", {
        scm {
          git "jenkinsci/job-dsl-plugin", {
            shallowClone true
          }
        }
      }
      Building on master in workspace /var/lib/jenkins/jobs/jenkins-dsl-test/workspace
       > git rev-parse --is-inside-work-tree # timeout=10
      Fetching changes from the remote Git repository
       > git config remote.origin.url git@github.com:jenkinsci/job-dsl-plugin # timeout=10
      Fetching upstream changes from git@github.com:jenkinsci/job-dsl-plugin
       > git --version # timeout=10
       > git -c core.askpass=true fetch --tags --progress git@github.com:jenkinsci/job-dsl-plugin +refs/heads/*:refs/remotes/origin/*
      Seen branch in repository origin/gh-pages
      Seen branch in repository origin/master
      Seen 2 remote branches
      Multiple candidate revisions
      Scheduling another build to catch up with jenkins-dsl-test
      Checking out Revision 31e9a5d7a4d9a5a1baf59f636608deee925e2270 (origin/gh-pages)
       > git config core.sparsecheckout # timeout=10
       > git checkout -f 31e9a5d7a4d9a5a1baf59f636608deee925e2270
      First time build. Skipping changelog.
       > git tag -a -f -m Jenkins Build #6 jenkins-jenkins-dsl-test-6 # timeout=10
      Finished: SUCCESS
      

      On the other hand if I do this:

      job "jenkins-dsl-test", {
        scm {
          git "git@github.com:jenkinsci/job-dsl-plugin"
        }
      
        configure { node ->
          node / 'scm' / 'extensions' / 'hudson.plugins.git.extensions.impl.CloneOption' {
            shallow 'true'
          }
        }
      }
      

      Then the depth flag is added and supposedly I get a shallow clone.

            daspilker Daniel Spilker
            balsamiqluis2 Luis Arias
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: