My Maven web application uses several JAR dependencies hosted as private GitHub packages. I’m trying to set up a CI/CD pipeline with CircleCI.
When CircleCI tries to build with mvn package, it fails with a 401 when attempting to install the private packages. I don’t know how to approach authenticating. I’ve added SSH deploy and user keys to the project settings, but that doesn’t seem to help Maven. I know that locally, I added a server tag with my personal access token to the .m2/conf/settings.xml file to authenticate. But what should I do within CircleCI? Googling hasn’t revealed anything.
Update: I included settings.xml with a hardcoded access token within the repository and included -gs ./settings.xml in my maven build command to point to it. Works but doubt this is best practice, so leaving the question open.
You can reference environment variables in your settings.xml. It’s best to keep the secrets in environment variables configured within the project settings. Then use the technique in this stackoverflow to access the values from the environment without having to commit them to your repo.