How do you publish a Maven artifact to Nexus from a pipeline?
IntermediateConceptBuild Tools and Artifact Repositories
Answer
Configure distributionManagement in pom.xml, matching <server> ids in settings.xml, then run mvn deploy.
<distributionManagement>
<repository>
<id>releases</id>
<url>https://nexus.example.com/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>https://nexus.example.com/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
mvn -B -s settings.xml deploy -DskipTests
Tests should already have run in an earlier stage.
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 `settings.xml` in Maven and how do CI builds use it?IntermediateWhat is the Maven Wrapper and why use it?BeginnerHow do you cache dependencies and speed up Maven builds in CI?Intermediate