简体   繁体   中英

Maven release plugin not using configured username

I am using maven-release-plugin:2.5.1. I need to configure it to connect to SVN using public/private key authentication. I'm having problems getting the configuration to use the correct username when attempting the SSH connection to SVN.

My deploy-settings.xml <server> config looks like:

<server>
  <id>my.server.org</id>
  <username>[XXXX]</username>
  <privateKey>/home/[YYYY]/.ssh/id_rsa</privateKey>
</server>

My pom.xml <scm> config looks like:

scm:svn:svn+ssh://my.server.org/data1/svns_zzzz/zzzz/path/to/the/project/trunk

My mvn command line looks like:

--batch-mode  release:clean release:prepare release:perform  
-s /home/[YYYY]/.m2/deploy-settings.xml 
-Dsettings.security=/home/[YYYY]/.m2/master-settings.xml 

When I tried the above configuration it failed. It could not commit the modified POM file to SVN. To help debug this problem, I set the following environment variable:

SVN_SSH="ssh -vvv"

When I did this, I saw in the debug statements too many authentication failures with a username other than the [XXXX] username defined in the <server> tag.

So then I tried to specify the username in the command line:

--batch-mode -Dusername=[XXXX] release:clean release:prepare release:perform...

That didn't work.

So then I tried to specify the username in the POM:

scm:svn:svn+ssh://[XXXX]@my.server.org/data1/svns_zzzz/zzzz/path/to/the/project/trunk

That didn't work either.

To debug and verify my [XXXX] username and /home/[YYYY]/.ssh/id_rsa key did in fact work, I added them to the environment variable:

SVN_SSH="ssh -vvv -l [XXXX] -i /home/[YYYY]/.ssh/id_rsa"

After setting the environment variable like this, it worked. The release plugin was able to successfully commit the modified POM file to SVN. So I know the username and password work.

So now the question is what is wrong with my Maven configuration? Setting the SVN_SSH environment variable helped diagnose the problem, and provides a work-around but I don't want to leave it as a long-term solution.

Any thoughts?

The release plugin forks the build, and doesn't pass the arguments you provide on the command line to the forked process by default. Try adding this: -Darguments="-s /home/[YYYY]/.m2/deploy-settings.xml -Dsettings.security=/home/[YYYY]/.m2/master-settings.xml" (note double quotes) to the current command line. This should pass the changes to the forked processes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM