无法执行目标org.apache.maven.plugins:maven-release-plugin;无法标记SCM

时间:2017-03-10 11:12:41

标签: git maven

我使用maven-release-plugin为我的项目准备版本。

我添加了这样的插件:

    <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <version>2.5.3</version>
    </plugin>

Git repo的设置如下:

  <scm>
    <url>http://my-repo.com:7990/projects/repos/my-project</url>
    <connection>scm:git:ssh://git@my-repo.com:7999/wrap/my-project.git</connection>
    <developerConnection>scm:git:ssh://git@my-repo.com:7999/wrap/my-project.git</developerConnection>
    <tag>my-project-1.1</tag>
  </scm>

然而,当我运行时:

  mvn release:prepare

我收到此错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:prepare (default-cli) on project my-project: Unable to tag SCM
[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] 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.

1 个答案:

答案 0 :(得分:0)

我面临着同样的问题。事实证明,Maven没有权限代表我发布到我的Github存储库。为了使它能够生成新的发行标签,这是必需的。我的项目是Jenkins插件,所以我found the answer in the Jenkins developer wiki

  

但是,如果您的插件托管在GitHub上,并且您为GitHub和jenkins-ci.org使用了不同的用户名和/或密码,则将命令行参数用作用户名/密码会导致错误。您将必须启动ssh-agent并导入您的私钥,以便发布插件可以访问GitHub存储库(请参见Adding a new SSH key to your GitHub account)...

当然,如果您还没有create a new SSH key and add it to your SSH client,那么第一步就是走。

这是我遵循的过程(根据上面链接中的说明)。

$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Generating public/private rsa key pair.
Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]

然后将新的SSH密钥添加到SSH代理。

eval "$(ssh-agent -s)"
Agent pid 59566

使用您喜欢的编辑器打开~/.ssh/config并添加以下内容:

Host *
 AddKeysToAgent yes
 UseKeychain yes
 IdentityFile ~/.ssh/id_rsa

然后运行:

$ ssh-add -K ~/.ssh/id_rsa

将公钥复制到剪贴板中

pbcopy < ~/.ssh/id_rsa.pub

转到Github,然后从头像旁边的V形框中选择 Settings> SSH和GPG密钥> New SSH密钥,粘贴公共密钥,值,并为其命名,以供日后识别并保存。

应该的。

然后转到Github