bamboo maven credentials (settings.xml)
Asked by Tobias L?bermann:

Hi everyone,

we have a Problem with our Bamboo maven builds and releases. We have Bamboo Version 5.6 and using maven in most of the configured projects. For dependency and atrifact managment we use a sonar nexus. On our Bamboo instance we have a lot of different projects which all have there own nexus repositories with credentials (at our nexus server).

Our Problem: Is there a smart way in Bamboo to store the Nexus Repository credentails (for each Projekt/Plan different) in a build plan?

Szenario: Each project uses its own settings.xml with the different mirrors and repository configuriation inside. At this time the settings.xml comes from the source code repository of each project, because we can't use a global settings.xml. The credentials for the nexus repositories musst be set in the settings.xml, but don't want to store passwords in the source code repo!

Is there a better way within bamboo to store settings.xml files for each build plan or project specific? Or how can we put the user/password dynamic in the settings.xml for each build?

The same problem appears when we want to do a "mvn release:prepare" or "mvn release:perform". There we have to set the scm credentials via bamboo variables like: "mvn release:perform -Dusername=${bamboo.username} -Dpassword=${bamboo.password}"  
But this won't work for the credentials which has to be set in the settings.xml (like nexus credentials)

I hope you understand our problem and someone have a short answer for us.  
Thank you in advanced

Tobias


Answers:
author: Tobias L?bermann
body: Hello Rafael,

thanks for your answer. We have now a possible solution, I just have forgotten to reply to my own question.

It is not possible to use system variables (like -Darguments=) in maven settings.xml out of the profiles tag, thats why it was not possible to put the bamboo variables inside the settings.xml. But maven allows to use environment variables in maven settings.xml and thats how it works.  
We set a bamboo variable which stores the nexus password and set this bamboo variable in the maven task as an environment variable. This environment variable is used in the settings.xml as password for nexus.

This works very well and the password is not be visible any more.

bambooVariable.PNG

settings.PNG

I hope this solution helps some other with the same problem.  
[](https://community.atlassian.com/t5/Bamboo-questions/bamboo-maven-credentials-settings-xml/qaq-p/196872?attachment-id=9519){#link_116915ed107c17}  
[](/tnckb94959/attachments/tnckb94959/bamboo-questions/6264/1/settings.PNG){#display_116915ed107c17_0}  
[](https://community.atlassian.com/t5/Bamboo-questions/bamboo-maven-credentials-settings-xml/qaq-p/196872?attachment-id=9520){#link_116915ed107c17_0}  
[](/tnckb94959/attachments/tnckb94959/bamboo-questions/6264/2/bambooVariable.PNG){#display_116915ed107c17_2}


author: rsperafico
body: Hello Tobias,

Thank you for your question.

Could you run your Maven task by providing "*arguments*" as parameter to your Maven release, please?

```
mvn ... "-Darguments=-Dusername=myuser -Dpassword=mypass"
```

It seems "*${-Dsth=sth}* " is not passed to maven release plugin, but the "*-Darguments=* " form should be. Please, refer to [Maven](http://maven.apache.org/maven-release/maven-release-plugin/prepare-mojo.html#arguments) for further information.

If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired.

Thank you for your understanding.

---

Kind regards,  
Rafael P. Sperafico  
Atlassian Support


author: Christopher Fouts
body: Where does Bamboo install the settings.xml file? Or more accurately, how can I make Bamboo use "my" settings.xml file that I store in /some_path/.m2/settings.xml in my Bamboo client?

comments: author: Yashwanth Duvvuru
body: Hi Christopher,  

Facing the same problem.Did you find any workaround?


author: James_Marble
body: In the "Goal" configuration field of the "Maven 3.x" task you can pass an argument to Maven specifying where to find your settings.xml file. For example:

--settings=/some_path/.m2/settings.xml clean install

If you are using the "Artifactory Maven 3" task, put it in the "Additional Maven Parameters" field instead.

See [Maven CLI Options Reference](http://maven.apache.org/ref/current/maven-embedder/cli.html) for details and other options.


author: Luiz Saggioro
body: But in this case, what are you doing with settings.xml? Do you have it in a repository and clone it? Do you have a task to just write it to a file?


Tags: bamboo-administration

bamboo-deployment