Getting authentication error using maven-release-plugin
Asked by Chris Flynn:

We are attempting a release in Bamboo using Maven. The maven-release-plugin creates a tag in Subversion and uploads a artifact to the Nexus release repo. Both Nexus and Subversion can authenticate with the same user. We are storing that users credentials in our settings.xml.

When we run this release process from my laptop the process works fine.

When we run the process from Bamboo the process fails with an authentication error in Subversion. Nexus has no problems authenticating.

When we pass in the same user's credentials using the "-D" parameters the process works fine.

Does anyone know why there is a problem using the encrypted credentials from the settings.xml file?

We are using Bamboo v5.15


Answers:
author: Chris Flynn
body: I believe the answer to this issue can be found at the below link. It is an issue with the Maven Release Plugin, not Bamboo.

<http://maven.apache.org/maven-release/maven-release-plugin/faq.html#credentials>

You add the the ***project.scm.id*** property to the POM file and set the property to a server id in Bamboo's setting.xml file. I used the same credentials that Maven uses for the Releases repository since that user exists in both my Nexus and Subversion repositories.

By setting this property the release plugin automatically knows to use the server credentials for committing code into Subversion. I plan on setting this property in a parent POM. That way the developers do not need to worry about including it and there is no extra setup when creating a release job in Bamboo.

```
<project>   ...    <properties>      <project.scm.id>my-scm-server<project.scm.id>    </properties>  </project>
```

One note -- I discovered an issue on Windows if the password contains special characters. Subversion did not handle the special characters very gracefully and the job failed. Luckily our Bamboo instance runs on a Linux server and the special character does not cause any problems on Linux.


author: robhit
body: Hi Chris,

What exactly the error is thrown in the logs?

Also, Could you check what user is used for starting the Bamboo?

comments: author: Chris Flynn
body: I should have added this to start with, thank you for the follow up.

The error message is below and appears to be coming from Subversion:

```
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:prepare (default-cli) on project my-api: Unable to commit files
[ERROR] Provider message:
[ERROR] The svn command failed.
[ERROR] Command output:
[ERROR] svn: E215004: Authentication failed and interactive prompting is disabled; see the --force-interactive option
[ERROR] svn: E215004: Commit failed (details follow):
[ERROR] svn: E215004: Unable to connect to a repository at URL 'https://mycompany.com/repo/my/app/my-api/trunk'
[ERROR] svn: E215004: No more credentials or we tried too many times.
[ERROR] Authentication failed
```

The user running Bamboo is different than the user in the settings.xml file which is what should be used for Nexus and Subversion.


author: Chris Flynn
body: Hi [@robhit](/t5/user/viewprofilepage/user-id/1132242),

Have you had any time to consider a solution to my problem? Thanks in advance for any help you can offer.


author: robhit
body: Hi [@Chris Flynn](/t5/user/viewprofilepage/user-id/591532),

Since this works locally, could you try to execute the same command using the user used to run the bamboo or the remote agent?


author: Chris Flynn
body: That is an excellent suggestion. I will try this and report back the results.


author: Chris Flynn
body: Hi [@robhit](/t5/user/viewprofilepage/user-id/1132242)

That was an excellent suggestion! Thank you for the help.

I was able to replicate the same problem we are experiencing in Bamboo on my local system and I now know why the problem is happening, although I don't know how it could be permanently fixed.

++**Results from the test:**++

1. The release plugin deploys artifacts with the credentials in the settings.xml file
2. The release plugin commits changes to Subversion using the credentials used to check out the code
3. **\[REALIZATION\]** -- I thought the release plugin used the credentials from the settings.xml for both the artifact deployment and the Subversion commit. This was an incorrect assumption!
4. Two pieces of background information
   1. The release plugin appears to run *svn **--non-interactive** commit*to commit changes back into Subversion
   2. I use TortoiseSVN to checkout the code from Subversion.
5. When TortoiseSVN ++**saves**++ the credentials used to checkout the code the release process completes **successfully**
6. When TortoiseSVN ++**does not save**++ the credentials used to checkout the code the release process ++**fails**++ with the above error message
7. **\[CONCLUSION\]** Bamboo does not save the credentials it uses to checkout the code in a way that they can be reused by the Subversion CLI utility.

For now we are passing the credentials in for each job running a release, however, ideally I would like to be able to reuse the credentials already setup in Bamboo when setting up the linked repository.


author: robhit
body: Hi [@Chris Flynn](/t5/user/viewprofilepage/user-id/591532),

How is your Bamboo configured to start? Are you using Windows Service to start your Bamboo? If you are using Windows service ensure that a local user account is used for the same.

See below document:

\* <https://confluence.atlassian.com/bamboo/running-bamboo-as-a-windows-service-as-the-local-user-416580754.html>

Thanks,

Robhit


author: Chris Flynn
body: Our Bamboo instance is running on a Linux server. There is a local account on the server that we use to start Bamboo.

Why does it matter how Bamboo is running? Or which account is running Bamboo?

We created linked repositories in Bamboo and provided Subversion credentials in the configuration for each linked repository. Bamboo uses the linked repository and the configured credentials to checkout code from Subversion.


author: Chris Flynn
body: [@robhit](/t5/user/viewprofilepage/user-id/1132242) -- thank you very much for your help. I believe I discovered a fix below.


Tags: bamboo-administration