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

git plugin doesn't support branch name contains slash ("/")

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • git-plugin

      When a branch contains slash , if we try to specify such a branch in "Branch Name" field, it will not be able to fetch such branches. If we leave branch name as **, the job can fetch branch name containing slash without problem.

      I am not a Java person, but this method looks suspicious in Branch.java, just trying to help debug

      private static String strip(String name)

      { return name.substring(name.indexOf('/', 5) + 1); }

          [JENKINS-14026] git plugin doesn't support branch name contains slash ("/")

          Stefan Hirche added a comment -

          Hi,
          I just ran into the same issue but the "use remote" workaround does not work. But maybe I forgot something.
          I use Jenkins 1.515 with Git-Plugin 1.4.0 and Git-Client-Plugin 1.0.6.
          The branch is named release/1.0.0.0, but I get this error, also if I use origin/release/1.0.0.0:

          Fetching changes from 1 remote Git repository
          Fetching upstream changes from repoName
          No candidate revisions
          ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
          java.io.FileNotFoundException: File 'C:\.jenkins\jobs\JobName\builds\2013-05-21_16-54-50\changelog.xml.temp' does not exist
          at org.apache.commons.io.FileUtils.openInputStream(FileUtils.java:137)
          at org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:1102)
          at org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:1120)
          at org.jenkinsci.plugins.multiplescms.MultiSCM.checkout(MultiSCM.java:127)
          at hudson.model.AbstractProject.checkout(AbstractProject.java:1369)
          at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:676)
          at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
          at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:581)
          at hudson.model.Run.execute(Run.java:1575)
          at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
          at hudson.model.ResourceController.execute(ResourceController.java:88)
          at hudson.model.Executor.run(Executor.java:241)

          So if there are any hints to my issue...

          BTW, anything is fine if I try to build branches like "master" or "develop"

          Stefan Hirche added a comment - Hi, I just ran into the same issue but the "use remote" workaround does not work. But maybe I forgot something. I use Jenkins 1.515 with Git-Plugin 1.4.0 and Git-Client-Plugin 1.0.6. The branch is named release/1.0.0.0, but I get this error, also if I use origin/release/1.0.0.0: Fetching changes from 1 remote Git repository Fetching upstream changes from repoName No candidate revisions ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job. java.io.FileNotFoundException: File 'C:\.jenkins\jobs\JobName\builds\2013-05-21_16-54-50\changelog.xml.temp' does not exist at org.apache.commons.io.FileUtils.openInputStream(FileUtils.java:137) at org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:1102) at org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:1120) at org.jenkinsci.plugins.multiplescms.MultiSCM.checkout(MultiSCM.java:127) at hudson.model.AbstractProject.checkout(AbstractProject.java:1369) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:676) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:581) at hudson.model.Run.execute(Run.java:1575) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:241) So if there are any hints to my issue... BTW, anything is fine if I try to build branches like "master" or "develop"

          Stefan Hirche added a comment -

          Hi,
          I just found the problem with the "remote workaround". I forgot that I renamed my remote. Using the correct remote name works.

          Stefan Hirche added a comment - Hi, I just found the problem with the "remote workaround". I forgot that I renamed my remote. Using the correct remote name works.

          Code changed in jenkins
          User: Vincent Latombe
          Path:
          src/main/java/hudson/plugins/git/GitSCM.java
          src/test/java/hudson/plugins/git/GitSCMTest.java
          http://jenkins-ci.org/commit/git-plugin/12b16252efb7f6ad0cb80ff04f7557b60f7bfaca
          Log:
          [FIXED JENKINS-14026] git plugin doesn't support branch name contains
          slash ("/")

          The main issue is to determine whether an input containing a slash is a
          qualified branch (remote followed by branch name) or a branch name on
          which the remote name needs to be prepended.

          When there is only one remote involved, that can be solved by prepending
          the remote name to the branch name if the branch name doesn't already
          start with the remote name.

          Note : This commit doesn't cover cases where the given branch name is a
          pattern

          Compare: https://github.com/jenkinsci/git-plugin/compare/ab720af8b26b^...12b16252efb7

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Vincent Latombe Path: src/main/java/hudson/plugins/git/GitSCM.java src/test/java/hudson/plugins/git/GitSCMTest.java http://jenkins-ci.org/commit/git-plugin/12b16252efb7f6ad0cb80ff04f7557b60f7bfaca Log: [FIXED JENKINS-14026] git plugin doesn't support branch name contains slash ("/") The main issue is to determine whether an input containing a slash is a qualified branch (remote followed by branch name) or a branch name on which the remote name needs to be prepended. When there is only one remote involved, that can be solved by prepending the remote name to the branch name if the branch name doesn't already start with the remote name. Note : This commit doesn't cover cases where the given branch name is a pattern Compare: https://github.com/jenkinsci/git-plugin/compare/ab720af8b26b ^...12b16252efb7

          Code changed in jenkins
          User: Vincent Latombe
          Path:
          src/main/java/hudson/plugins/git/GitSCM.java
          src/test/java/hudson/plugins/git/GitSCMTest.java
          http://jenkins-ci.org/commit/git-plugin/13c2b08009fce7273051739acae19cfaa4d76b17
          Log:
          [FIXED JENKINS-14026] git plugin doesn't support branch name contains
          slash ("/")

          The main issue is to determine whether an input containing a slash is a
          qualified branch (remote followed by branch name) or a branch name on
          which the remote name needs to be prepended.

          When there is only one remote involved, that can be solved by prepending
          the remote name to the branch name if the branch name doesn't already
          start with the remote name.

          Note : This commit doesn't cover cases where the given branch name is a
          pattern

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Vincent Latombe Path: src/main/java/hudson/plugins/git/GitSCM.java src/test/java/hudson/plugins/git/GitSCMTest.java http://jenkins-ci.org/commit/git-plugin/13c2b08009fce7273051739acae19cfaa4d76b17 Log: [FIXED JENKINS-14026] git plugin doesn't support branch name contains slash ("/") The main issue is to determine whether an input containing a slash is a qualified branch (remote followed by branch name) or a branch name on which the remote name needs to be prepended. When there is only one remote involved, that can be solved by prepending the remote name to the branch name if the branch name doesn't already start with the remote name. Note : This commit doesn't cover cases where the given branch name is a pattern

          Code changed in jenkins
          User: Nicolas De loof
          Path:
          src/main/java/hudson/plugins/git/GitSCM.java
          src/test/java/hudson/plugins/git/GitSCMTest.java
          http://jenkins-ci.org/commit/git-plugin/a67bbc0062fa4dd4d27b8113f3a27840b53dded9
          Log:
          Merge pull request #187 from jenkinsci/JENKINS-14026

          [FIXED JENKINS-14026] git plugin doesn't support branch name contains

          Compare: https://github.com/jenkinsci/git-plugin/compare/b75d1e21dc75...a67bbc0062fa

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nicolas De loof Path: src/main/java/hudson/plugins/git/GitSCM.java src/test/java/hudson/plugins/git/GitSCMTest.java http://jenkins-ci.org/commit/git-plugin/a67bbc0062fa4dd4d27b8113f3a27840b53dded9 Log: Merge pull request #187 from jenkinsci/ JENKINS-14026 [FIXED JENKINS-14026] git plugin doesn't support branch name contains Compare: https://github.com/jenkinsci/git-plugin/compare/b75d1e21dc75...a67bbc0062fa

          Daniel Spilker added a comment - The fix broke the ability to checkout tags. See https://github.com/jenkinsci/git-plugin/commit/a67bbc0062fa4dd4d27b8113f3a27840b53dded9#commitcomment-5140751

          Code changed in jenkins
          User: Nicolas De Loof
          Path:
          src/main/java/hudson/plugins/git/GitSCM.java
          src/test/java/hudson/plugins/git/GitSCMTest.java
          http://jenkins-ci.org/commit/git-plugin/c94ac36ff6f410ce8b7f5859b0ff9b0468a5681b
          Log:
          Revert "Merge pull request #187 from jenkinsci/JENKINS-14026"

          This reverts commit a67bbc0062fa4dd4d27b8113f3a27840b53dded9, reversing
          changes made to b75d1e21dc75c8143f99baea0342169123a409c8.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nicolas De Loof Path: src/main/java/hudson/plugins/git/GitSCM.java src/test/java/hudson/plugins/git/GitSCMTest.java http://jenkins-ci.org/commit/git-plugin/c94ac36ff6f410ce8b7f5859b0ff9b0468a5681b Log: Revert "Merge pull request #187 from jenkinsci/ JENKINS-14026 " This reverts commit a67bbc0062fa4dd4d27b8113f3a27840b53dded9, reversing changes made to b75d1e21dc75c8143f99baea0342169123a409c8.

          Code changed in jenkins
          User: Vincent Latombe
          Path:
          src/main/java/hudson/plugins/git/util/DefaultBuildChooser.java
          http://jenkins-ci.org/commit/git-plugin/ea5cad7e2759d0c9f5ed723fe590f982b0bb818d
          Log:
          JENKINS-14026 DefaultBuildChooser should handle smartly branches with /

          When encountering a single branch containing a '/', it is either a qualified branch or a branch containing a '/'
          In the first case, the branch should start with the name of a declared remote
          Otherwise, we fall back to unqualified behaviour, and we try to match the branch name as if it was */BRANCH

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Vincent Latombe Path: src/main/java/hudson/plugins/git/util/DefaultBuildChooser.java http://jenkins-ci.org/commit/git-plugin/ea5cad7e2759d0c9f5ed723fe590f982b0bb818d Log: JENKINS-14026 DefaultBuildChooser should handle smartly branches with / When encountering a single branch containing a '/', it is either a qualified branch or a branch containing a '/' In the first case, the branch should start with the name of a declared remote Otherwise, we fall back to unqualified behaviour, and we try to match the branch name as if it was */BRANCH

          Code changed in jenkins
          User: Nicolas De loof
          Path:
          src/main/java/hudson/plugins/git/util/DefaultBuildChooser.java
          http://jenkins-ci.org/commit/git-plugin/b22146d14997edaaf9bd95a054c65b623606d379
          Log:
          Merge pull request #195 from Vlatombe/JENKINS-14026

          JENKINS-14026 DefaultBuildChooser should handle smartly branches with /

          Compare: https://github.com/jenkinsci/git-plugin/compare/dcae49362fc1...b22146d14997

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nicolas De loof Path: src/main/java/hudson/plugins/git/util/DefaultBuildChooser.java http://jenkins-ci.org/commit/git-plugin/b22146d14997edaaf9bd95a054c65b623606d379 Log: Merge pull request #195 from Vlatombe/ JENKINS-14026 JENKINS-14026 DefaultBuildChooser should handle smartly branches with / Compare: https://github.com/jenkinsci/git-plugin/compare/dcae49362fc1...b22146d14997

          Mark Waite added a comment -

          Branch names containing slashes and tag based checkout are both supported since git client plugin 1.10.0 through the commit submitted by Alexander Link. The online help for the "Branches to build" field has been updated to explain the extended syntax.

          The extended syntax allows the plugin to continue supporting the old format branch specifiers and still allow specification of branch names with embedded slash characters (like develop/my-branch). The extended syntax also allows checkout of tags.

          Mark Waite added a comment - Branch names containing slashes and tag based checkout are both supported since git client plugin 1.10.0 through the commit submitted by Alexander Link. The online help for the "Branches to build" field has been updated to explain the extended syntax. The extended syntax allows the plugin to continue supporting the old format branch specifiers and still allow specification of branch names with embedded slash characters (like develop/my-branch). The extended syntax also allows checkout of tags.

            Unassigned Unassigned
            hayafirst Yi Wen
            Votes:
            4 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: