【问题标题】:Jenkins + git: "tell me who you are" error, why does it need to tag?Jenkins + git:“告诉我你是谁”错误,为什么需要标记?
【发布时间】:2012-06-20 15:27:21
【问题描述】:

刚刚在 Ubuntu 12.04 中安装了 Jenkins,我想创建一个简单的构建,它只是克隆一个项目并构建它。

它失败是因为它无法标记。它无法标记,因为它错误地说“告诉我你是谁”显然是因为我没有设置 git 设置 UserName 和 UserEmail。

但是,我不需要设置这些,Jenkins 将只是克隆存储库,如果它不打算推送更改,为什么它需要凭据,为什么它根本需要做一个标记?

完整的错误日志是:

Started by user anonymous
Checkout:workspace / /var/lib/jenkins/jobs/Foo.Bar.Baz/workspace - hudson.remoting.LocalChannel@38e609c9
Using strategy: Default
Cloning the remote Git repository
Cloning repository origin
Fetching upstream changes from git@mygithost.mydomain.local:foo-bar-baz/foo-bar-baz.git
Seen branch in repository origin/1.0
Seen branch in repository origin/1.5.4
Seen branch in repository origin/HEAD
Seen branch in repository origin/master
Commencing build of Revision 479d37776b46283a946dd395c1ea78f18c0b97c7 (origin/1.0)
Checking out Revision 479d37776b46283a946dd395c1ea78f18c0b97c7 (origin/1.0)
FATAL: Could not apply tag jenkins-Foo.Bar.Baz-2
hudson.plugins.git.GitException: Could not apply tag jenkins-Foo.Bar.Baz-2
at hudson.plugins.git.GitAPI.tag(GitAPI.java:737)
at hudson.plugins.git.GitSCM$4.invoke(GitSCM.java:1320)
at hudson.plugins.git.GitSCM$4.invoke(GitSCM.java:1268)
at hudson.FilePath.act(FilePath.java:758)
at hudson.FilePath.act(FilePath.java:740)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1268)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1193)
at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:565)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:453)
at hudson.model.Run.run(Run.java:1376)
at hudson.matrix.MatrixBuild.run(MatrixBuild.java:220)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:175)
at hudson.model.OneOffExecutor.run(OneOffExecutor.java:66)
Caused by: hudson.plugins.git.GitException: Command "git tag -a -f -m Jenkins Build #2 jenkins-Foo.Bar.Baz-2" returned status code 128:
stdout: 
stderr: 
*** Please tell me who you are.

    Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: empty ident  <jenkins@somehostname.(none)> not allowed

    at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:786)
    at hudson.plugins.git.GitAPI.launchCommand(GitAPI.java:748)
    at hudson.plugins.git.GitAPI.launchCommand(GitAPI.java:758)
    at hudson.plugins.git.GitAPI.tag(GitAPI.java:735)
    ... 13 more

【问题讨论】:

  • 嗯!配置了user.name和user.email之后,构建成功了,但是它在服务器中创建了一个名为“1.0”的新标签,为什么git插件在默认配置中如此奇怪以及如何配置它所以它不会这样做?

标签: git jenkins jenkins-plugins


【解决方案1】:

至于如何设置user.email和user.name, 在 jenkins 中,转到“管理 Jenkins”>“配置系统” 并向下滚动到“Git 插件”,你会发现

输入您的电子邮件和姓名,一切顺利。

【讨论】:

  • 我有那套,但好像没用过。
  • 如果您的 Jenkins 管理员访问受限,另一种选择是在作业配置的 Git 插件部分添加“附加行为”。您可以选择其他行为来添加仅适用于您的工作而非全局设置的自定义用户名/电子邮件地址。
【解决方案2】:

我使用了 iecanfly 上面的解决方案。使用我的 git 用户名和密码不起作用,我 输入了

用户名:詹金斯

电子邮件:jenkins@localhost

这解决了问题。

【讨论】:

    【解决方案3】:

    您也可以通过 SSH 进入 Jenkins 并导航到工作区目录,然后您可以正常运行 git config user.name 和 user.email 命令。

    【讨论】:

    • 由于我们的服务器托管限制,我无法通过 SSH 访问 Jenkins。
    • 我可以 SSH 和 git 在命令行中工作,但不能在 Jenkins 中工作。 @iecanfly 的解决方案似乎对我有用。
    【解决方案4】:

    在提取/克隆 repo 时标记的想法对于大多数 Build Scheduler 来说很常见:
    Hudson-Jenkins,还有CruiseControl(由labelincrementer确定的构建标签),或者RTC Jazz Build Engine (where they are called "snapshots")

    这个想法是将输入的持久记录设置为构建。
    这样一来,即使没有标记,构建调度程序也会自动为您标记您正在提取的代码,以便以后能够返回到该特定构建。

    如果设置了该策略(始终在构建之前进行标记),那么 Jenkins 将需要知道你是谁才能制作一个 git 标签(它是一个带有作者的 git 对象:user.name 和 @ 987654330@)。

    但是,如“Why hudson/jenkins tries to make commit?”中所述:

    检查“Source code management”部分中“Advanced...”下的“Skip internal tag”配置。

    这应该避免您似乎不需要的额外标记步骤。

    【讨论】:

    【解决方案5】:

    如果您在 Docker 容器中运行 Jenkins,则需要在容器中执行 docker exec -it &lt;CONTAINER_ID&gt; sh,然后使用您的电子邮件和姓名运行建议的 git 命令。

    【讨论】:

      猜你喜欢
      • 2012-07-24
      • 2015-12-17
      • 2016-04-03
      • 2020-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多