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

Using refspec without url causes checkout to fail

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Major Major
    • git-plugin
    • None
    • Git Plugin 3.10.0
      Git Client Plugin 2.7.7
      Jenkins 2.176.2

      For some reason when we clone with refspec specified the remote added is origin1 instead of origin.

       

      Checkout Command:

      scmVars = checkout([$class: 'GitSCM',
      branches: [[name: "$Branch"]],
      doGenerateSubmoduleConfigurations: false,
      extensions: [
      [$class: 'GitLFSPull'],
      [$class: 'CheckoutOption', timeout: 120],
      [$class: 'CleanBeforeCheckout'],
      [$class: 'CloneOption', noTags: false, timeout: 60],
      [$class: 'LocalBranch', localBranch: '${BRANCH}']
      ],
      gitTool: 'Default', submoduleCfg: [],
      userRemoteConfigs: [
      [refspec: '+refs/heads/main:refs/remotes/origin/main +refs/heads/dev/*:refs/remotes/origin/dev/* +refs/heads/release/*:refs/remotes/origin/release/* +refs/tags/*:refs/tags/*'],
      [credentialsId: '***', url: '****']
      ]
      ])
      checkout([$class: 'GitSCM',
      branches: [[name: "$Branch2"]],
      doGenerateSubmoduleConfigurations: false,
      extensions: [
      [$class: 'GitLFSPull'],
      [$class: 'CheckoutOption', timeout: 120],
      [$class: 'CleanBeforeCheckout'],
      [$class: 'RelativeTargetDirectory', relativeTargetDir: '../branch2']
      ],
      gitTool: 'Default', submoduleCfg: [],
      userRemoteConfigs: [
      [refspec: '+refs/heads/main:refs/remotes/origin/main +refs/heads/dev/*:refs/remotes/origin/dev/* +refs/heads/release/*:refs/remotes/origin/release/* +refs/tags/*:refs/tags/*'],
      [credentialsId: '****', url: '****']
      ]
      ])

       

       

      Build Log (with stuff redacted):

      14:31:44 No credentials specified
      14:31:44 using credential ****
      14:31:44 Fetching changes from the remote Git repository
      14:31:44 Cleaning workspace
      14:31:44 > git rev-parse --is-inside-work-tree # timeout=10
      14:31:44 > git config remote.origin1.url **** # timeout=10
      14:31:44 > git rev-parse --verify HEAD # timeout=10
      14:31:44 Resetting working tree
      14:31:44 > git reset --hard # timeout=10
      14:32:00 > git clean -fdx # timeout=10
      14:32:59 Fetching upstream changes from ****
      14:32:59 > git --version # timeout=10
      14:32:59 using GIT_ASKPASS to set credentials for accessing git repo
      14:32:59 > git fetch --tags --force --progress **** +refs/heads/:refs/remotes/origin1/ # timeout=60
      14:33:11 Checking out Revision 4b7d7fe66b0f61cce5fb28aed2659928d3929ea8 (origin/dev/macmain)
      14:33:11 Enabling Git LFS pull
      14:33:11 > git rev-parse origin/dev/macmain^{commit} # timeout=10
      14:33:11 > git rev-parse refs/remotes/origin1/origin/dev/macmain^{commit} # timeout=10
      14:33:11 > git config core.sparsecheckout # timeout=10
      14:33:11 > git checkout -f 4b7d7fe66b0f61cce5fb28aed2659928d3929ea8 # timeout=120
      14:33:12 > git branch -a -v --no-abbrev # timeout=10
      14:33:12 > git checkout -b origin/dev/macmain 4b7d7fe66b0f61cce5fb28aed2659928d3929ea8 # timeout=120
      14:33:13 > git config --get remote.origin1.url # timeout=10
      14:33:13 using GIT_ASKPASS to set credentials for accessing git repo
      14:33:13 > git lfs pull origin1 # timeout=120
      14:33:32 Commit message: "Some commit"
      14:33:32 First time build. Skipping changelog.

       

      Removing the refspec fixes the issue and origin is the name of the remote.

      If you clone on the machine manually then let jenkins take over you will have 2 remotes the original origin from the clone and a new origin1. This can cause your build to use an older commit instead of the latest.

            markewaite Mark Waite
            raihaan Raihaan Shouhell
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: