What is `settings.xml` in Maven and how do CI builds use it?
IntermediateConceptBuild Tools and Artifact Repositories
Answer
~/.m2/settings.xml (or -s file) holds mirrors, server credentials, proxies and profiles. In CI, define a mirror pointing at your Nexus/Artifactory group repository so all downloads go through the proxy cache, and inject credentials via environment variables rather than committing them.
<settings>
<mirrors>
<mirror>
<id>central-proxy</id>
<mirrorOf>*</mirrorOf>
<url>https://nexus.example.com/repository/maven-public/</url>
</mirror>
</mirrors>
<servers>
<server>
<id>releases</id>
<username>${env.NEXUS_USER}</username>
<password>${env.NEXUS_PASS}</password>
</server>
</servers>
</settings>
More on Build Tools and Artifact Repositories
What is Maven and what is its build lifecycle?BeginnerWhat is the difference between `mvn package`, `install` and `deploy`?BeginnerHow do Maven dependency scopes and transitive dependencies work?IntermediateWhat is the Maven Wrapper and why use it?BeginnerHow do you cache dependencies and speed up Maven builds in CI?IntermediateWhat is the difference between `npm install` and `npm ci`?Beginner