我有一个托管在 Git stash 中的项目(现在更名为 Bitbucket Server)。它是使用 Jenkins 构建的。现在我在本地安装我的 Git 时打错了。喜欢 @ab.example
而不是 @abc.example
每次构建后,Jenkins 都会发送电子邮件通知,它会从 Git 提交中提取我不正确的电子邮件地址并尝试发送它。
即使我在本地 Git 中更改了电子邮件地址,我仍然看到 Jenkins 将电子邮件发送到旧的错误地址。
我怎样才能解决这个问题?
Post-build Actions
中尝试 Editable Email Notification
。您可以通过文字字符串或电子邮件地址变量来定义收件人列表。对于早期提交中的错误邮件,您可以使用 git filter-branch --env-filter
进行修改。但这会重写提交历史。不建议这样做。
本地设置的电子邮件地址(分别为每个存储库)
打开 Git Bash。将当前工作目录更改为要在其中设置 Git 配置电子邮件的本地存储库。使用以下命令设置您的电子邮件地址:
git config user.email "your_email@abc.example"
使用以下命令确认您已正确设置电子邮件地址。
git config user.email
全局设置电子邮件地址(仅在本地未设置任何内容时使用)
打开 Git Bash。使用以下命令设置您的电子邮件地址:
git config --global user.email "your_email@abc.example"
确认您已设置电子邮件地址:
git config --global user.email
或者使用环境变量
GIT_COMMITTER_EMAIL=your_email@abc.example GIT_AUTHOR_EMAIL=your_email@abc.example
PD:来自 GitHub 官方指南的信息
根据 git 文档,您所要做的就是重新运行
$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
然后只需检查以确保更改生效
$ git config --list
这在 Scott Chacon 和 Ben Straub 所著的 Pro Git 书中列出
1.6 入门 - 首次 Git 设置
利用
"git -c user.name="你的名字" -c user.email=youremail@email.com 提交 --amend --reset-author"
要设置您的全局用户名/电子邮件配置:
打开命令行。设置您的用户名: git config --global user.name "FIRST_NAME LAST_NAME" 设置您的电子邮件地址: git config --global user.email "MY_NAME@example.com"
要设置存储库特定的用户名/电子邮件配置:
从命令行,切换到存储库目录。设置您的用户名:git config user.name "FIRST_NAME LAST_NAME" 设置您的电子邮件地址:git config user.email "MY_NAME@example.com" 通过显示配置文件来验证您的配置:cat .gitconfig
有关更多信息和其他版本控制系统.. => SeeThis
直接在 JENKINS_HOME/users/YOUR_NAME/config.xml
配置文件中编辑您的电子邮件并重新启动 Jenkins 服务器
解释的命令在本地设置 .git/config 中的电子邮件:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = https://username:password@git.mydomain.io/username/repo.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[branch "beta"]
remote = origin
merge = refs/heads/beta
[user]
email = pippo.caio@sempronio.io
不定期副业成功案例分享
git config --get user.email
来检查值