【问题标题】:Jenkins - tagging a build fails with NoHeadExceptionJenkins - 标记构建失败并出现 NoHeadException
【发布时间】:2018-03-22 07:25:47
【问题描述】:

当我尝试通过 Jenkins 标记特定构建时,我收到以下错误:

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

当尝试在工作区中进行标记时,它工作正常,实际上附加了 HEAD,git refs 看起来很好,这可能是 Jenkins 尝试标记时在错误的工作目录中查找的问题吗?

有没有办法提取更详细的日志以及它如何尝试标记?

仅供参考 - 使用 Jenkins 2.81 和 swarm Linux 代理,最新的 Git 插件。

【问题讨论】:

    标签: eclipse git jenkins tags


    【解决方案1】:

    考虑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);
    

    仔细检查您的配置:请参阅“Jenkins Git plugin detached HEAD”。您需要确保 Jenkins 确实检查了一个分支。
    例如,尝试添加一个包含 git status 的简单测试步骤,以验证这一点。

    【讨论】:

    • 我检查了我的配置,它看起来不错,在构建期间,我可以毫无问题地标记,当我想在之后标记特定构建时,即遇到该错误时。问题是我不想标记每个构建,我需要在事后标记某些构建。当您单击构建和显示“无标签”的部分时,我会标记功能。当我检查工作区时,git status/refs 看起来不错,并且手动标记工作正常,它通过 Jenkins 打破了已经构建的构建。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-11-25
    • 1970-01-01
    • 1970-01-01
    • 2021-11-11
    • 2020-05-07
    • 1970-01-01
    • 2013-10-15
    相关资源
    最近更新 更多