mvn release to push to git using a specific private key











up vote
1
down vote

favorite












I hope someone can help with this. I'm trying to configure the mvn release plugin in pom.xml so that the updated pom version and tag are pushed to the git repo as part of release:prepare. Crucially, it needs to use the ssh private key of a specific user, as ultimately this will be part of our CI stack.



In the pom.xml I currently have a very simple config for the release plugin:



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


The scm settings in the pom look like this:



<scm>
<connection>scm:git:git://ssh@bitbucket.org/**account**/**project**.git</connection>
<developerConnection>scm:git:ssh://git@bitbucket.org/**account**/**project**.git</developerConnection>
<url>https://bitbucket.org/**account**/**project**</url>
</scm>


And I have the following property in the pom (though not sure if this is used or not - I found reference to it on a loosely related problem):



<properties>
<project.scm.id>bitbucket.org</project.scm.id>


Lastly, I have the following in mvn's settings.xml :



<servers>
<server>
<id>bitbucket.org</id>
<privateKey>~/.ssh/bitbucket-read-write-access</privateKey>
<passphrase></passphrase>
</server>


The private key file ~/.ssh/bitbucket-read-write-access exists, and there are no other keys in that folder (I have deliberately removed the default id_rsa)



When I run mvn release:perform, it fails when it tries to push to the repo:



[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] git@bitbucket.org: 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.


The only way I can get it to push correctly is to rename the file ~/.ssh/bitbucket-read-write-access to ~/.ssh/id_rsa which leads me to believe that:




  • The user associated with the private key has the correct permissions on the repo and the public key is correctly associated with the repo user

  • My configuration of the pom.xml and/or settings.xml is not quite right in respect of choosing/using the desired private key


(Before anyone suggests it, I cannot simply rename the key to ~/.ssh/id_rsa because when we run this on the CI stack, it already has a default ssh key for another purpose)



Any thoughts or help with this would be very much appreciated





Some additional info:

If I do export GIT_SSH_COMMAND="ssh -i ~/.ssh/bitbucket-read-write-access" then git push, it pushes fine, which further leads me to believe the private/public key are correctly configured; and it's the mvn config that is wrong.










share|improve this question
























  • You declared a <passphrase> that's empty. Is that intentional? Are there further information when running mvn ... -X?
    – Gerold Broser
    Nov 9 at 17:39












  • @GeroldBroser - I've tried it with the empty <passphrase>, a self-closing <passphrase/> and no element at all - all 3 options give the same result. Re: mvn... -X, yes, I've tried it, but nothing additional is logged in this respect
    – Nathan Russell
    Nov 9 at 21:16















up vote
1
down vote

favorite












I hope someone can help with this. I'm trying to configure the mvn release plugin in pom.xml so that the updated pom version and tag are pushed to the git repo as part of release:prepare. Crucially, it needs to use the ssh private key of a specific user, as ultimately this will be part of our CI stack.



In the pom.xml I currently have a very simple config for the release plugin:



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


The scm settings in the pom look like this:



<scm>
<connection>scm:git:git://ssh@bitbucket.org/**account**/**project**.git</connection>
<developerConnection>scm:git:ssh://git@bitbucket.org/**account**/**project**.git</developerConnection>
<url>https://bitbucket.org/**account**/**project**</url>
</scm>


And I have the following property in the pom (though not sure if this is used or not - I found reference to it on a loosely related problem):



<properties>
<project.scm.id>bitbucket.org</project.scm.id>


Lastly, I have the following in mvn's settings.xml :



<servers>
<server>
<id>bitbucket.org</id>
<privateKey>~/.ssh/bitbucket-read-write-access</privateKey>
<passphrase></passphrase>
</server>


The private key file ~/.ssh/bitbucket-read-write-access exists, and there are no other keys in that folder (I have deliberately removed the default id_rsa)



When I run mvn release:perform, it fails when it tries to push to the repo:



[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] git@bitbucket.org: 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.


The only way I can get it to push correctly is to rename the file ~/.ssh/bitbucket-read-write-access to ~/.ssh/id_rsa which leads me to believe that:




  • The user associated with the private key has the correct permissions on the repo and the public key is correctly associated with the repo user

  • My configuration of the pom.xml and/or settings.xml is not quite right in respect of choosing/using the desired private key


(Before anyone suggests it, I cannot simply rename the key to ~/.ssh/id_rsa because when we run this on the CI stack, it already has a default ssh key for another purpose)



Any thoughts or help with this would be very much appreciated





Some additional info:

If I do export GIT_SSH_COMMAND="ssh -i ~/.ssh/bitbucket-read-write-access" then git push, it pushes fine, which further leads me to believe the private/public key are correctly configured; and it's the mvn config that is wrong.










share|improve this question
























  • You declared a <passphrase> that's empty. Is that intentional? Are there further information when running mvn ... -X?
    – Gerold Broser
    Nov 9 at 17:39












  • @GeroldBroser - I've tried it with the empty <passphrase>, a self-closing <passphrase/> and no element at all - all 3 options give the same result. Re: mvn... -X, yes, I've tried it, but nothing additional is logged in this respect
    – Nathan Russell
    Nov 9 at 21:16













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I hope someone can help with this. I'm trying to configure the mvn release plugin in pom.xml so that the updated pom version and tag are pushed to the git repo as part of release:prepare. Crucially, it needs to use the ssh private key of a specific user, as ultimately this will be part of our CI stack.



In the pom.xml I currently have a very simple config for the release plugin:



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


The scm settings in the pom look like this:



<scm>
<connection>scm:git:git://ssh@bitbucket.org/**account**/**project**.git</connection>
<developerConnection>scm:git:ssh://git@bitbucket.org/**account**/**project**.git</developerConnection>
<url>https://bitbucket.org/**account**/**project**</url>
</scm>


And I have the following property in the pom (though not sure if this is used or not - I found reference to it on a loosely related problem):



<properties>
<project.scm.id>bitbucket.org</project.scm.id>


Lastly, I have the following in mvn's settings.xml :



<servers>
<server>
<id>bitbucket.org</id>
<privateKey>~/.ssh/bitbucket-read-write-access</privateKey>
<passphrase></passphrase>
</server>


The private key file ~/.ssh/bitbucket-read-write-access exists, and there are no other keys in that folder (I have deliberately removed the default id_rsa)



When I run mvn release:perform, it fails when it tries to push to the repo:



[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] git@bitbucket.org: 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.


The only way I can get it to push correctly is to rename the file ~/.ssh/bitbucket-read-write-access to ~/.ssh/id_rsa which leads me to believe that:




  • The user associated with the private key has the correct permissions on the repo and the public key is correctly associated with the repo user

  • My configuration of the pom.xml and/or settings.xml is not quite right in respect of choosing/using the desired private key


(Before anyone suggests it, I cannot simply rename the key to ~/.ssh/id_rsa because when we run this on the CI stack, it already has a default ssh key for another purpose)



Any thoughts or help with this would be very much appreciated





Some additional info:

If I do export GIT_SSH_COMMAND="ssh -i ~/.ssh/bitbucket-read-write-access" then git push, it pushes fine, which further leads me to believe the private/public key are correctly configured; and it's the mvn config that is wrong.










share|improve this question















I hope someone can help with this. I'm trying to configure the mvn release plugin in pom.xml so that the updated pom version and tag are pushed to the git repo as part of release:prepare. Crucially, it needs to use the ssh private key of a specific user, as ultimately this will be part of our CI stack.



In the pom.xml I currently have a very simple config for the release plugin:



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


The scm settings in the pom look like this:



<scm>
<connection>scm:git:git://ssh@bitbucket.org/**account**/**project**.git</connection>
<developerConnection>scm:git:ssh://git@bitbucket.org/**account**/**project**.git</developerConnection>
<url>https://bitbucket.org/**account**/**project**</url>
</scm>


And I have the following property in the pom (though not sure if this is used or not - I found reference to it on a loosely related problem):



<properties>
<project.scm.id>bitbucket.org</project.scm.id>


Lastly, I have the following in mvn's settings.xml :



<servers>
<server>
<id>bitbucket.org</id>
<privateKey>~/.ssh/bitbucket-read-write-access</privateKey>
<passphrase></passphrase>
</server>


The private key file ~/.ssh/bitbucket-read-write-access exists, and there are no other keys in that folder (I have deliberately removed the default id_rsa)



When I run mvn release:perform, it fails when it tries to push to the repo:



[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] git@bitbucket.org: 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.


The only way I can get it to push correctly is to rename the file ~/.ssh/bitbucket-read-write-access to ~/.ssh/id_rsa which leads me to believe that:




  • The user associated with the private key has the correct permissions on the repo and the public key is correctly associated with the repo user

  • My configuration of the pom.xml and/or settings.xml is not quite right in respect of choosing/using the desired private key


(Before anyone suggests it, I cannot simply rename the key to ~/.ssh/id_rsa because when we run this on the CI stack, it already has a default ssh key for another purpose)



Any thoughts or help with this would be very much appreciated





Some additional info:

If I do export GIT_SSH_COMMAND="ssh -i ~/.ssh/bitbucket-read-write-access" then git push, it pushes fine, which further leads me to believe the private/public key are correctly configured; and it's the mvn config that is wrong.







git maven ssh






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 9 at 16:36

























asked Nov 9 at 16:02









Nathan Russell

1,32321941




1,32321941












  • You declared a <passphrase> that's empty. Is that intentional? Are there further information when running mvn ... -X?
    – Gerold Broser
    Nov 9 at 17:39












  • @GeroldBroser - I've tried it with the empty <passphrase>, a self-closing <passphrase/> and no element at all - all 3 options give the same result. Re: mvn... -X, yes, I've tried it, but nothing additional is logged in this respect
    – Nathan Russell
    Nov 9 at 21:16


















  • You declared a <passphrase> that's empty. Is that intentional? Are there further information when running mvn ... -X?
    – Gerold Broser
    Nov 9 at 17:39












  • @GeroldBroser - I've tried it with the empty <passphrase>, a self-closing <passphrase/> and no element at all - all 3 options give the same result. Re: mvn... -X, yes, I've tried it, but nothing additional is logged in this respect
    – Nathan Russell
    Nov 9 at 21:16
















You declared a <passphrase> that's empty. Is that intentional? Are there further information when running mvn ... -X?
– Gerold Broser
Nov 9 at 17:39






You declared a <passphrase> that's empty. Is that intentional? Are there further information when running mvn ... -X?
– Gerold Broser
Nov 9 at 17:39














@GeroldBroser - I've tried it with the empty <passphrase>, a self-closing <passphrase/> and no element at all - all 3 options give the same result. Re: mvn... -X, yes, I've tried it, but nothing additional is logged in this respect
– Nathan Russell
Nov 9 at 21:16




@GeroldBroser - I've tried it with the empty <passphrase>, a self-closing <passphrase/> and no element at all - all 3 options give the same result. Re: mvn... -X, yes, I've tried it, but nothing additional is logged in this respect
– Nathan Russell
Nov 9 at 21:16

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53229242%2fmvn-release-to-push-to-git-using-a-specific-private-key%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53229242%2fmvn-release-to-push-to-git-using-a-specific-private-key%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini