1

When I try to tag a specific build through Jenkins, I get the following error:

ERROR: Error tagging repo 'refs/remotes/origin/master' :
org.eclipse.jgit.api.errors.NoHeadException: Tag on repository without
HEAD currently not supported hudson.plugins.git.GitException:
org.eclipse.jgit.api.errors.NoHeadException: Tag on repository without
HEAD currently not supported    at
org.jenkinsci.plugins.gitclient.JGitAPIImpl.tag(JGitAPIImpl.java:509)
    at
hudson.plugins.git.GitTagAction$TagWorkerThread.perform(GitTagAction.java:199)
    at hudson.model.TaskThread.run(TaskThread.java:129) Caused by:
org.eclipse.jgit.api.errors.NoHeadException: Tag on repository without
HEAD currently not supported    at
org.eclipse.jgit.api.TagCommand.call(TagCommand.java:137)   at
org.jenkinsci.plugins.gitclient.JGitAPIImpl.tag(JGitAPIImpl.java:507)
    ... 2 more Trying next branch Completed

When trying to tag in the workspace it works fine, HEAD is in fact attached, git refs look fine, could this be an issue that when Jenkins is trying to tag it is looking in the wrong working directory?

Is there a way to pull more verbose logs with how it's trying to tag?

FYI - using the Jenkins 2.81, and swarm Linux agents, latest Git plugin.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250

1 Answers1

0

Consider the actual code throwing the exception:

    try (RevWalk revWalk = new RevWalk(repo)) {
        // if no id is set, we should attempt to use HEAD
        if (id == null) {
            ObjectId objectId = repo.resolve(Constants.HEAD + "^{commit}"); //$NON-NLS-1$
            if (objectId == null)
                throw new NoHeadException(
                    JGitText.get().tagOnRepoWithoutHEADCurrentlyNotSupported);

Double-check your configuration: see "Jenkins Git plugin detached HEAD". You need to make sure Jenkins actually does checkout a branch.
Try for instance to add a simple test step with a git status in it, to validate that.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I have checked my configuration, it looks good, during build time, I can tag with no issues, when I want to tag a specific build after, that is when I run into that error. The issue is that I don't want to tag every single build, I need to tag certain builds after the fact. I tag through functionality when you click into the build and the section that says "no tags". When I check the workspace, git status/refs look good, and tagging manually works just fine, its through Jenkins that it's breaking on an already built build. – Artem Kulikov Oct 12 '17 at 12:58