Maven release:prepare unable to commit to Git repository when using a CI

147 views Asked by At

I am using Quickbuild as my CI. When using Maven's release management plugin and running the release:prepare command, I am getting an error committing the tag to my Git repository. This is most likely because of a permissions error.

I've read solutions to use maven options -Dusername=<username> -Dpassword=<password but given that multiple users can see this configuration, I'd prefer to hide or encrypt the credentials.

I haven't found anything online and was wondering if someone has come across this.

1

There are 1 answers

3
Patrick Cookson On BEST ANSWER

Maven has a built in tool for encrypting passwords for use in your settings.xml. One thing you could try is to add the Git repository to the server tag in your settings file.

So, for example, in the settings.xml file you could add:

<server>
    <id>git-repo-location</id> 
    <username>your username</username>
    <password>{EncycptedPassword=}</password>
</server> 

To encrypt your password in Maven, open the command line and use:

mvn --encrypt-password yourPasswordHere

Copy what it returns and paste it into the settings.xml.