When you build and deploy to a Nexus Repository using the Jenkins plugin, you need to provide the artifact, group, and version information to the Jenkins pipeline script. This information can be automatically extracted from the pom.xml using the readMavenPom Pipeline Utility Step.
Here is an example Publish stage from a Pipeline script:
stage('Publish') { def pom = readMavenPom file: 'pom.xml' nexusPublisher nexusInstanceId: 'nexus3', \ nexusRepositoryId: 'releases', \ packages: [[$class: 'MavenPackage', \ mavenAssetList: [[classifier: '', extension: '', \ filePath: "target/${pom.artifactId}-${pom.version}.${pom.packaging}"]], \ mavenCoordinate: [artifactId: "${pom.artifactId}", \ groupId: "${pom.groupId}", \ packaging: "${pom.packaging}", \ version: "${pom.version}"]]] }
Make sure the Pipeline Utility Steps plugin is installed in Jenkins "Manage Plugins". If you do not have the plugin installed you may see an error: java.lang.NoSuchMethodError: No such DSL method 'readMavenPom' .