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

Git "Tag to push" should trim whitespace

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: git-plugin
    • Labels:
      None
    • Similar Issues:

      Description

      Using git plugin 1.1.17.

      If you accidentally leave in whitespace in the "Tag to push" field, git will create a tag with the whitespace replaced by an "_". E.g. if you configure a tag like "build-$

      {BUILD_NUMBER}

      " (note the whitespace at the end of the field), the created tag will then be "build-121_" or the like.

      The tag will be created locally but pushing the tag will fail because it will try to push the tag without the "_", and this tag will not exist.

      Pushing tag build-121  to repo origin
      ERROR: Failed to push tag build-121  to origin
      hudson.plugins.git.GitException: Command "git push git-company@server.company.com:/srv/company.git build-121 " returned status code 128:
      stdout: 
      stderr: fatal: remote part of refspec is not a valid name in build-121 
      
      	at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:779)
      	at hudson.plugins.git.GitAPI.launchCommand(GitAPI.java:741)
      	at hudson.plugins.git.GitAPI.push(GitAPI.java:797)
      	at hudson.plugins.git.GitPublisher$3.invoke(GitPublisher.java:277)
      	at hudson.plugins.git.GitPublisher$3.invoke(GitPublisher.java:247)
      	at hudson.FilePath.act(FilePath.java:832)
      	at hudson.FilePath.act(FilePath.java:814)
      	at hudson.plugins.git.GitPublisher.perform(GitPublisher.java:247)
      	at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36)
      	at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:705)
      	at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:680)
      	at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:658)
      	at hudson.model.Build$RunnerImpl.post2(Build.java:162)
      	at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:627)
      	at hudson.model.Run.run(Run.java:1446)
      	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
      	at hudson.model.ResourceController.execute(ResourceController.java:88)
      	at hudson.model.Executor.run(Executor.java:238)
      Build step 'Git Publisher' changed build result to FAILURE
      

      This error kind of pointed me in the wrong direction and it took some time to figure this out, it would be really great if the field could be trimmed, hopefully it will save some people some time if they have this same problem. Alternatively, you could give an error when leaving whitespace in the "Tag to push" field.

        Attachments

          Activity

            People

            • Assignee:
              ndeloof Nicolas De Loof
              Reporter:
              willemst Willem Stuursma
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: