jenkinsci / jenkinsci/git-plugin

[JENKINS-56205] Git Publisher Pushes Tags as Branches (JGit)

Open
#3,405 0 comments 0 reactions 0 assignees View on GitHub
component:git-plugin imported-jira-issue priority:minor resolution:unresolved
Dominant language
Java
Stars
694
Forks
1.1k
Avg merge
1h 29m
Merged PRs (30d)
3

Description

When creating and pushing a tag with the Git Publisher, it gets pushed to the remote repository as a branch. The console output shows:

```
Pushing tag 4.6.44.0.5 to repo XXX
RefSpec is "refs/tags/4.6.44.0.5:refs/heads/4.6.44.0.5".

```

This appears to be caused by a combination of:



  • Line 272 in hudson.plugins.git.GitPublisher (in git-plugin)


    • PushCommand push = git.push().to(remoteURI).ref(tagName);
      




  • The call to fixRefSpec() in org.jenkinsci.plugins.gitclient.JGitAPIImpl

    • This class is in git-client-plugin

    • Without a full reference passed to PushCommand.ref(), it defaults to prepending the name with "/refs/heads".

    • It should probably default to the prefix used in the source ref rather than "heads"



I don't know if the bug/fix is in git-plugin or git-client-plugin - probably the latter because the CLI client may work fine.

---
Originally reported by donalob, imported from: Git Publisher Pushes Tags as Branches (JGit)


  • status: Open
  • priority: Minor
  • component(s): git-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 1
  • imported: 2025-12-02

Raw content of original issue

When creating and pushing a tag with the Git Publisher, it gets pushed to the remote repository as a branch. The console output shows:



Pushing tag 4.6.44.0.5 to repo XXX

RefSpec is "refs/tags/4.6.44.0.5:refs/heads/4.6.44.0.5".


This appears to be caused by a combination of:



  • Line 272 in hudson.plugins.git.GitPublisher (in git-plugin)


    • PushCommand push = git.push().to(remoteURI).ref(tagName);
      





  • The call to fixRefSpec() in org.jenkinsci.plugins.gitclient.JGitAPIImpl

    • This class is in git-client-plugin

    • Without a full reference passed to PushCommand.ref(), it defaults to prepending the name with "/refs/heads".

    • It should probably default to the prefix used in the source ref rather than "heads"



I don't know if the bug/fix is in git-plugin or git-client-plugin - probably the latter because the CLI client may work fine.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.