Interview Prep/CI/CD/Build Tools and Artifact Repositories

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.

All CI/CD questions Roadmap: CI/CD fundamentals

More on Build Tools and Artifact Repositories