[JIRA] (JENKINS-59540) Using refspec causes checkout to fail

7 views
Skip to first unread message

raihaan.shouhell@autodesk.com (JIRA)

unread,
Sep 26, 2019, 6:07:04 AM9/26/19
to jenkinsc...@googlegroups.com
Raihaan Shouhell created an issue
 
Jenkins / Bug JENKINS-59540
Using refspec causes checkout to fail
Issue Type: Bug Bug
Assignee: Mark Waite
Components: git-plugin
Created: 2019-09-26 10:06
Environment: Git Plugin 3.10.0
Git Client Plugin 2.7.7
Jenkins 2.176.2
Priority: Major Major
Reporter: Raihaan Shouhell

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.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

mark.earl.waite@gmail.com (JIRA)

unread,
Sep 26, 2019, 6:53:02 AM9/26/19
to jenkinsc...@googlegroups.com
Mark Waite updated Bug JENKINS-59540
 

There is a subtle syntax error in the checkout syntax that you are using. The declaration is using two userRemoteConfig values when I believe that you want one.

Your syntax is:

userRemoteConfigs: [
  [refspec: ''], // Creates an entry with null URL, null credentials ID
  [credentialsId: '**', url: '****']
]

The desired syntax is:

 
                                                            

userRemoteConfigs: [
[refspec: '', credentialsId: '**', url: '****']
]

 
                                                            
Change By: Mark Waite
Status: Open Fixed but Unreleased
Resolution: Not A Defect

mark.earl.waite@gmail.com (JIRA)

unread,
Sep 26, 2019, 6:54:03 AM9/26/19
to jenkinsc...@googlegroups.com
There is a subtle syntax error in the checkout syntax that you are using.  The declaration is using two {{userRemoteConfig}} values when I believe that you want one.

Your syntax is:

{noformat}

userRemoteConfigs: [
  [refspec: ''], // Creates an entry with null URL, null credentials ID
  [credentialsId: '**', url: '****']
]
{noformat}

The desired syntax is:
{noformat}
{noformat}

userRemoteConfigs: [
  [refspec: '', credentialsId: '**', url: '****']
]
{noformat}

mark.earl.waite@gmail.com (JIRA)

unread,
Sep 26, 2019, 6:54:03 AM9/26/19
to jenkinsc...@googlegroups.com
Change By: Mark Waite
Status: Fixed but Unreleased Closed
Reply all
Reply to author
Forward
0 new messages