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

GIT_BRANCH_SHORT for branch name without release/, feature/, etc. Just the bit after the '/'

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • git-plugin
    • None

      For cases where a filename expansion is needed for the git branch name, thre cannot be a '/' in a filename, so that part of the branch needs to be dropped.
      ie:
      GIT_BRANCH=release/blue-fish
      then:
      GIT_BRANCH_SHORT=blue-fish

      Seems like a simple thing to do in the plugin, but not possible to do in a job.

          [JENKINS-21421] GIT_BRANCH_SHORT for branch name without release/, feature/, etc. Just the bit after the '/'

          Thomas Reinhardt added a comment - - edited

          This would be especially handy with the "Check out to specific local branch" option. At the moment we have set this fixed to "master" but that prevents the build of multiple branches. To be more specific, the build itself works fine but "M2 Release Plugin" can not push tags back to origin when no local branch is present (see this discussion on stackoverflow).

          Specifing the local branch as ${GIT_BRANCH}
          kind of works but duplicates the leading "origin/" part. ${GIT_BRANCH,fullName=false} does not expand the variable at all.

          I will try to implement that tomorrow.

          Thomas Reinhardt added a comment - - edited This would be especially handy with the "Check out to specific local branch" option. At the moment we have set this fixed to "master" but that prevents the build of multiple branches. To be more specific, the build itself works fine but "M2 Release Plugin" can not push tags back to origin when no local branch is present (see this discussion on stackoverflow ). Specifing the local branch as ${GIT_BRANCH} kind of works but duplicates the leading "origin/" part. ${GIT_BRANCH,fullName=false} does not expand the variable at all. I will try to implement that tomorrow.

          I have created a pull request that fixes this issue.

          Thomas Reinhardt added a comment - I have created a pull request that fixes this issue.

            Unassigned Unassigned
            bedge Bruce Edge
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: