我希望有人能帮忙解决这个问题。我正在尝试配置mvn release
插件pom.xml
这样更新的 pom 版本和标签就会作为 git repo 的一部分推送到release:prepare
。至关重要的是,它需要使用特定用户的ssh私钥,因为最终这将成为我们 CI 堆栈的一部分。
In the pom.xml
我目前有一个非常简单的发布插件配置:
<build>
<plugins>
<!-- release plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
</plugin>
The scm
pom 中的设置如下所示:
<scm>
<connection>scm:git:git://[email protected] /cdn-cgi/l/email-protection/**account**/**project**.git</connection>
<developerConnection>scm:git:ssh://[email protected] /cdn-cgi/l/email-protection/**account**/**project**.git</developerConnection>
<url>https://bitbucket.org/**account**/**project**</url>
</scm>
我在 pom 中有以下属性(尽管不确定是否使用了它 - 我发现在一个松散相关的问题上引用了它):
<properties>
<project.scm.id>bitbucket.org</project.scm.id>
最后,我在 mvn 中有以下内容settings.xml
:
<servers>
<server>
<id>bitbucket.org</id>
<privateKey>~/.ssh/bitbucket-read-write-access</privateKey>
<passphrase></passphrase>
</server>
私钥文件~/.ssh/bitbucket-read-write-access
存在,并且该文件夹中没有其他键(我故意删除了默认的id_rsa
)
当我跑步时mvn release:perform
,当它尝试推送到存储库时失败:
[INFO] Executing: /bin/sh -c cd /home/nathanrussell/projects/**project** && git push ssh:********@bitbucket.org/**account**/**project**.git refs/heads/master:refs/heads/master
[INFO] Working directory: /home/nathanrussell/projects/**project**
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.162 s
[INFO] Finished at: 2018-11-09T15:25:36Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:prepare (default-cli) on project **project**: Unable to commit files
[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] [email protected] /cdn-cgi/l/email-protection: Permission denied (publickey).
[ERROR] fatal: Could not read from remote repository.
[ERROR]
[ERROR] Please make sure you have the correct access rights
[ERROR] and the repository exists.
我可以让它正确推送的唯一方法是重命名文件~/.ssh/bitbucket-read-write-access
to ~/.ssh/id_rsa
这让我相信:
- 与私钥关联的用户对存储库具有正确的权限,并且公钥与存储库用户正确关联
- 我的配置
pom.xml
and/or settings.xml
在选择/使用所需的私钥方面不太正确
(在有人建议之前,我不能简单地将密钥重命名为~/.ssh/id_rsa
因为当我们在 CI 堆栈上运行它时,它已经有一个用于其他目的的默认 ssh 密钥)
任何对此的想法或帮助将非常感激
一些附加信息:
如果我做export GIT_SSH_COMMAND="ssh -i ~/.ssh/bitbucket-read-write-access"
then git push
,它推得很好,这进一步让我相信私钥/公钥配置正确;这是 mvn 配置错误的。