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

Git Publisher should allow ForceTag instead of CreateTag

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

      There is a common development pattern that is not currently possible with the git plugin (as far as I can tell). I want to be able to tag a recently passed commit (with an already existing tag) and push that back to the origin repository.

      So the idea being that currently my git history looks like this:

      40f7af3 2012-05-17 | new commit
      2738f9f 2012-05-17 | previous commit (passed)
      fbafd82 2012-05-17 | older commit

      When 40f7af3 gets pushed and tested, if it passes it should now get the `passed` tag.

      40f7af3 2012-05-17 | new commit (passed)
      2738f9f 2012-05-17 | previous commit
      fbafd82 2012-05-17 | older commit

      If we replace CreateTag with a ForceTag checkbox, this behavior will now be possible, as will all of the previous options with createtag.

      In code, all the checkbox would have to do is enable the `-f` flag while performing the git tag command. (This is already built into the API).

          [JENKINS-13833] Git Publisher should allow ForceTag instead of CreateTag

          I think this is exactly what the "Update new tag" option is for (though I agree that its name is misleading and probably should have said "Force create new tag" instead).

          Sebastian Schuberth added a comment - I think this is exactly what the "Update new tag" option is for (though I agree that its name is misleading and probably should have said "Force create new tag" instead).

          Alex V added a comment -

          From the help text :
          If the "Create Tag" or "Update tag" option is selected, the tag will be created or updated and pushed at the completion of the build, *and the push will fail if a tag with the given name already exists*. If the "Create Tag" option is not selected, the push will fail if the tag does not already exist.

          => There is no way at the moment (I am using git plugin 2.2.4) to "create if needed, or update an existing tag".
          I want to have a tag "last-success-in-<branchname>" per branch ( and only one ), and I think it is not possible right now.
          At the moment I have to add the build number to the tag, which spam my repo with useless tags.

          ERROR: Failed to push tag origin/develop-build-success to origin
          hudson.plugins.git.GitException: Command "git push https://github.com/asmodehn/WkCocos.git origin/develop-build-success" returned status code 1:
          stdout:
          stderr: To https://github.com/asmodehn/WkCocos.git
          ! [rejected] origin/develop-build-success -> origin/develop-build-success (already exists)
          error: failed to push some refs to 'https://github.com/asmodehn/WkCocos.git'
          hint: Updates were rejected because the tag already exists in the remote.

          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1407)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1195)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$200(CliGitAPIImpl.java:87)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$7.execute(CliGitAPIImpl.java:1462)
          at org.jenkinsci.plugins.gitclient.LegacyCompatibleGitAPIImpl.push(LegacyCompatibleGitAPIImpl.java:98)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.push(CliGitAPIImpl.java:87)
          at org.jenkinsci.plugins.gitclient.LegacyCompatibleGitAPIImpl.push(LegacyCompatibleGitAPIImpl.java:109)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.push(CliGitAPIImpl.java:87)
          at hudson.plugins.git.GitAPI.push(GitAPI.java:66)
          at hudson.plugins.git.GitPublisher.perform(GitPublisher.java:276)
          at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
          at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:772)
          at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:736)
          at hudson.model.Build$BuildExecution.post2(Build.java:183)
          at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:685)
          at hudson.model.Run.execute(Run.java:1757)
          at com.tikal.jenkins.plugins.multijob.MultiJobBuild.run(MultiJobBuild.java:73)
          at hudson.model.ResourceController.execute(ResourceController.java:88)
          at hudson.model.Executor.run(Executor.java:234)
          Build step 'Git Publisher' marked build as failure

          Alex V added a comment - From the help text : If the "Create Tag" or "Update tag" option is selected, the tag will be created or updated and pushed at the completion of the build, * and the push will fail if a tag with the given name already exists *. If the "Create Tag" option is not selected, the push will fail if the tag does not already exist. => There is no way at the moment (I am using git plugin 2.2.4) to "create if needed, or update an existing tag". I want to have a tag "last-success-in-<branchname>" per branch ( and only one ), and I think it is not possible right now. At the moment I have to add the build number to the tag, which spam my repo with useless tags. ERROR: Failed to push tag origin/develop-build-success to origin hudson.plugins.git.GitException: Command "git push https://github.com/asmodehn/WkCocos.git origin/develop-build-success" returned status code 1: stdout: stderr: To https://github.com/asmodehn/WkCocos.git ! [rejected] origin/develop-build-success -> origin/develop-build-success (already exists) error: failed to push some refs to 'https://github.com/asmodehn/WkCocos.git' hint: Updates were rejected because the tag already exists in the remote. at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1407) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1195) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$200(CliGitAPIImpl.java:87) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$7.execute(CliGitAPIImpl.java:1462) at org.jenkinsci.plugins.gitclient.LegacyCompatibleGitAPIImpl.push(LegacyCompatibleGitAPIImpl.java:98) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.push(CliGitAPIImpl.java:87) at org.jenkinsci.plugins.gitclient.LegacyCompatibleGitAPIImpl.push(LegacyCompatibleGitAPIImpl.java:109) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.push(CliGitAPIImpl.java:87) at hudson.plugins.git.GitAPI.push(GitAPI.java:66) at hudson.plugins.git.GitPublisher.perform(GitPublisher.java:276) at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:772) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:736) at hudson.model.Build$BuildExecution.post2(Build.java:183) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:685) at hudson.model.Run.execute(Run.java:1757) at com.tikal.jenkins.plugins.multijob.MultiJobBuild.run(MultiJobBuild.java:73) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:234) Build step 'Git Publisher' marked build as failure

            Unassigned Unassigned
            akoumjian Alec Koumjian
            Votes:
            4 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: