Jenkins + git:“告诉我你是谁”错误,为什么需要打标签?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11122913/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jenkins + git: "tell me who you are" error, why does it need to tag?
提问by knocte
Just installed Jenkins in Ubuntu 12.04 and I wanted to create a simple build that just clones a project and builds it.
刚刚在 Ubuntu 12.04 中安装了 Jenkins,我想创建一个简单的构建,它只是克隆一个项目并构建它。
It fails because it cannot tag. It cannot tag because it errors out saying "tell me who you are" apparently because I didn't set git settings UserName and UserEmail.
它失败了,因为它无法标记。它无法标记,因为它错误地说“告诉我你是谁”显然是因为我没有设置 git 设置 UserName 和 UserEmail。
But, I should not need to set those, Jenkins is going to just clone the repository, why does it need the credentials if it's not going to push changes, why does it need to do a tag at all?
但是,我不需要设置这些,Jenkins 将只克隆存储库,如果它不打算推送更改,为什么它需要凭据,为什么它根本需要做标记?
Full error log is:
完整的错误日志是:
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 [email protected]: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.invoke(GitSCM.java:1320)
at hudson.plugins.git.GitSCM.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 "[email protected]"
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
采纳答案by VonC
The idea of tagging when pulling/cloning a repo is common to most Build Scheduler out there:
Hudson-Jenkins, but also CruiseControl(The build label determined by the labelincrementer
), or RTC Jazz Build Engine (where they are called "snapshots").
在拉取/克隆 repo 时标记的想法对于大多数 Build Scheduler 是常见的:
Hudson-Jenkins,还有CruiseControl(由 确定的构建标签labelincrementer
)或RTC Jazz Build Engine(它们被称为“快照”)。
The idea is to set a persistent record of the inputto a build.
That way, the code you are pulling, even if it wasn't tagged, is tagged automatically for you by the build scheduler, in order to be able to get back to that specific build later.
这个想法是为构建设置一个持久的输入记录。
这样,即使没有标记,您正在拉取的代码也会由构建调度程序自动为您标记,以便稍后能够返回到该特定构建。
If that policy (always tagging before a build) is set, then Jenkins will need to know who you are in order to make a git tag (it is a git object with an author attached to it: user.name
and user.email
).
如果设置了该策略(始终在构建之前标记),那么 Jenkins 将需要知道您是谁才能制作 git 标记(它是一个附有作者的 git 对象:user.name
和user.email
)。
However, as mentioned in " Why hudson/jenkins tries to make commit?":
但是,正如“为什么 hudson/jenkins 尝试提交?”中所述:
Checks "
Skip internal tag
" config under "Advanced...
" in section "Source code management
".
检查“
Skip internal tag
”Advanced...
部分中“Source code management
”下的“ ”配置。
That should avoid that extra tagging step you appear to not need.
这应该避免您似乎不需要的额外标记步骤。
回答by iecanfly
As for how to set user.email and user.name,
In jenkins, go to "Manage Jenkins" > "Configure System"
and scroll down to "Git plugin" and there you will find
至于如何设置user.email和user.name,在jenkins中,进入“Manage Jenkins”>“Configure System”,向下滚动到“Git plugin”,你会发现
enter your email and name, you're good to go.
输入您的电子邮件和姓名,您就可以开始了。
回答by diptia
I used the solution above by iecanfly . Using my git user name and password didnt work , I entered
我使用了上面的解决方案 iecanfly 。使用我的 git 用户名和密码不起作用,我输入了
username : jenkins
用户名:詹金斯
email : jenkins@localhost
电子邮件:jenkins@localhost
That fixed the issue.
这解决了问题。
回答by Kvass
You can also SSH into Jenkins and navigate over to the workspace directory, and then you can just run the git config user.name and user.email commands normally.
您也可以通过 SSH 进入 Jenkins 并导航到工作区目录,然后您可以正常运行 git config user.name 和 user.email 命令。
回答by Ogala
If you are running Jenkins in a Docker container, you'd need to exec into the container docker exec -it <CONTAINER_ID> sh
then run the suggested git commands with your email and name.
如果您在 Docker 容器中运行 Jenkins,则需要执行到容器中,docker exec -it <CONTAINER_ID> sh
然后使用您的电子邮件和姓名运行建议的 git 命令。