9

I am trying to deploy my Maven project which is hosted on Github. I have generated and added my public key to Github, and also I think I have filled the pom.xml with all the required properties:

<licenses>
    <license>
        <name>MIT License</name>
        <url>http://www.opensource.org/licenses/mit-license.php</url>
    </license>
</licenses>

<developers>
    <developer>
        <name>Hristo Vrigazov</name>
        <email>[email protected]</email>
        <organization>Hribol</organization>
        <organizationUrl>https://github.com/hristo-vrigazov</organizationUrl>
    </developer>
</developers>

<scm>
    <connection>scm:git:git://github.com/hristo-vrigazov/bromium.git</connection>
    <developerConnection>scm:git:git://github.com/hristo-vrigazov/bromium.git</developerConnection>
    <url>https://github.com/hristo-vrigazov/bromium</url>
    <tag>com.hribol.bromium.dsl.parent-1.0.0</tag>
</scm>

I am trying to release as follows:

ssh-add ~/.ssh/github_rsa
ssh-add -l
mvn release:prepare release:perform -B -e | tee maven-central-deploy.log

However, I keep getting this message from Maven, indicating that there is a problem with my SSH key:

Provider message:
The git-push command failed.
Command output:
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.


at org.apache.maven.plugins.release.PrepareReleaseMojo.prepareRelease(PrepareReleaseMojo.java:299)
at org.apache.maven.plugins.release.PrepareReleaseMojo.execute(PrepareReleaseMojo.java:247)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
Caused by: 
org.apache.maven.shared.release.scm.ReleaseScmCommandException: Unable to tag SCM
Provider message:
The git-push command failed.
Command output:
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

What could be the reason? I was able to deploy the snapshots to Nexus.

2 Answers 2

9

You are using the wrong protocol (the "git" one) in your URL:

<connection>scm:git:git://github.com/hristo-vrigazov/bromium.git</connection>

It should be using ssh:

<connection>scm:git:ssh://[email protected]/hristo-vrigazov/bromium.git</connection>

or

<connection>scm:git:[email protected]:hristo-vrigazov/bromium.git</connection>

(same for developerConnection)
Only then, your ssh key would be used.

1
  • 1
    I found that error after upgrading one of Java dependency and problem has gone after applying that fix
    – Damian
    Commented Jun 23, 2023 at 22:25
-2

Make sure if you are using profiles, to specify -P in the arguments of the mvn release:command

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.