[JIRA] (JENKINS-50401) Checkout resolution misbehaves with local branch and forward slashes

11 views
Skip to first unread message

stephan@codefreeze.ch (JIRA)

unread,
Mar 26, 2018, 9:00:02 AM3/26/18
to jenkinsc...@googlegroups.com
Stephan Hauser created an issue
 
Jenkins / Bug JENKINS-50401
Checkout resolution misbehaves with local branch and forward slashes
Issue Type: Bug Bug
Assignee: Mark Waite
Components: git-plugin
Created: 2018-03-26 12:59
Environment: Jenkins 2.107.1, git-plugin 2.7.1
Priority: Minor Minor
Reporter: Stephan Hauser

If the git plugin uses a local branch which is named the same as the remote and contains a forward slash, it will cause the checkout command to not update to the latest commit. Since using branches with / is common and local branch might be necessary, this should be fixed or at least produce a warning.

To test: Create the following pipeline:

node {
  stage ('hello') {
    dir ('foo') {
      checkout([$class: 'GitSCM', branches: [[name: "foo/bar"]], extensions: [[$class: 'LocalBranch', localBranch: 'foo/bar']], userRemoteConfigs: [[credentialsId: '...', url: "..."]]])
    }
  }
}

And follow these steps:

  1. Push branch foo/bar
  2. Run pipeline
  3. Push branch foo/bar with new versions
  4. Re-run pipeline in same folder

The output should have the following contents:

 > git.exe fetch --tags --progress ssh://xxxx +refs/heads/*:refs/remotes/origin/*
 > git.exe rev-parse "foo/bar^{commit}" # timeout=10
 > git.exe rev-parse "refs/remotes/origin/foo/bar^{commit}" # timeout=10
Multiple candidate revisions
Checking out Revision 7bbd0143e31f1280e032cf350cf9f466642d1d65 (foo/bar)

The 7bbd014 is the older commit however, since the local branch takes precedence over the remote one.

Workarounds:

  • Name the local branch differently from the remote branch
  • Specify the fully quialified branch name (remotes/origin/$ {branch}

    ) in the checkout command

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

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

unread,
May 18, 2018, 11:06:01 PM5/18/18
to jenkinsc...@googlegroups.com
Mark Waite assigned an issue to Unassigned
Change By: Mark Waite
Assignee: Mark Waite

jh-jenkins-ci@drowl.co.uk (JIRA)

unread,
Oct 22, 2018, 2:10:03 PM10/22/18
to jenkinsc...@googlegroups.com
James Housley commented on Bug JENKINS-50401
 
Re: Checkout resolution misbehaves with local branch and forward slashes

I was having this issue when using "origin" as the "Name" of my git repository in the job's settings, and then using e.g. "abc/def" as my branch specifier. Removing the Name and instead using "origin/abc/def" as my branch specifier fixed the issue.

This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

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

unread,
Dec 9, 2018, 9:54:02 AM12/9/18
to jenkinsc...@googlegroups.com

manuelramonleonjimenez@gmail.com (JIRA)

unread,
Jan 3, 2020, 8:29:02 AM1/3/20
to jenkinsc...@googlegroups.com
Ramon Leon commented on Bug JENKINS-50401
 
Re: Checkout resolution misbehaves with local branch and forward slashes

Mark Waite I'm a bit confused about this. Is it fixed actually? Which version? I saw this PR but it was closed without merging https://github.com/jenkinsci/branch-api-plugin/pull/47

Thank you.

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

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

unread,
Jan 4, 2020, 10:53:03 AM1/4/20
to jenkinsc...@googlegroups.com

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

unread,
Jan 4, 2020, 10:53:03 AM1/4/20
to jenkinsc...@googlegroups.com
Change By: Mark Waite
Resolution: Fixed
Status: Fixed but Unreleased Reopened

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

unread,
Jan 4, 2020, 10:58:03 AM1/4/20
to jenkinsc...@googlegroups.com
Mark Waite commented on Bug JENKINS-50401
 
Re: Checkout resolution misbehaves with local branch and forward slashes

Ramon Leon I don't remember why I marked this as fixed but not released without linking a pull request or providing some other comment to justify that change.  Neither this bug nor either of the linked bugs are mentioned in the [git plugin 4.0.0 changelog|https://github.com/jenkinsci/git-plugin/releases/tag/git-4.0.0] or in the [git client plugin 3.0.0 changelog|https://github.com/jenkinsci/git-client-plugin/releases/tag/git-client-3.0.0].  I've corrected my mistake and placed it back into 'OPEN' state.

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

unread,
Jan 4, 2020, 11:00:02 AM1/4/20
to jenkinsc...@googlegroups.com
Mark Waite edited a comment on Bug JENKINS-50401
[~mramonleon] I don't remember why I marked this as fixed but not released without linking a pull request or providing some other comment to justify that change.  Neither this bug nor either of the linked bugs are mentioned in the [git plugin 4.0.0 changelog| [ https://github.com/jenkinsci/git-plugin/releases/tag/git-4.0.0] ] or in the [git client plugin 3.0.0 changelog| [ https://github.com/jenkinsci/git-client-plugin/releases/tag/git-client-3.0.0 |https://github.com/jenkinsci/git-plugin/releases/tag/git-4.0.0 ] ] .  I've corrected my mistake and placed it back into 'OPEN' state.
Reply all
Reply to author
Forward
0 new messages