1
votes

I have a project structure like this:

- parent-project : pom.xml
  + child-project: pom.xml
  + child-project-2: pom.xml

I would like to upload the artifact of child-project to Nexus, so in pom.xml file of my child-project, I defined:

    <distributionManagement>
        <repository>
            <id>nexus</id>
            <url>http://my-repo:8081/repository/maven-releases/</url>
        </repository>
        <snapshotRepository>
            <id>nexus</id>
            <url>http://my-repo:8081/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

And when I run the child-project with mvn clean deploy from eclipse, the jar file of child-project is uploaded to my-repo nexus repository as expected.

In Jenkins I have an job which is configured with the parent-project pom.xml. Now I would like to publish the artifact of my child-project to nexus after jenkins finished the build process. What I have done so far is:

  1. Downloaded and installed the Nexus Platform Plugin in Jenkins
  2. Configured the Nexus Repository Manager Servers with the credential to my Nexus 3.x Server in Jenkins System Configuration
  3. In the Post-Build tab, I added a new Nexus Repository Manager Publisher with the Info about my nexus repository but now getting stuck at the Maven Artifact session as below: enter image description here

What make me confused here are:

  1. what should I put in the Maven Artifact session? I tried child-project/target/child-project-0.0.1-SNAPSHOT.jar but it did not work. Jenkins threw an exception

java.io.IOException: child-project/target/child-project-0.0.1-SNAPSHOT.jar does not exist

  1. Why do I need to specify the version of the artifact here? Does it mean that every time I change the version of my child-project, then I have to come here and modify the version?
  2. If I already defined in pom.xml of my child-project the session with Info about the Nexus repo, why do I need to define it here again?
  3. Is it possible that I configure the job build directly with mvn clean deploy like I did in eclipse to push the artifact to nexus? If yes then I dont need the Nexus Repository Manager Publisher anymore? And how can I configure the authentication for the nexus server like what I have in setting.xml in my /.m2 folder?

Can anyone help me to clarify the points above? Thank you very much!

1
just use a maven project and in the Build section add mvn clean deploy also you can click on the advance tab to specify the settings.xml file location.rohit thomas

1 Answers

0
votes

you don't need the plugin you can run maven clean install deploy from shell in your job I'm using pipeline syntax so it's actual code but you can use jenkins ui to create a shell step