- create a freestyle job sample_nexus, use https://github.com/zhuby1973/myapp.git as SCM

2. in Build section, select “Invoke top-level Maven targets” with Goals: clean package deploy

3. vi /etc/maven/settings.xml, add admin id for nexus:
<server> <id>deployment</id> <username>admin</username> <password>pas8word</password> </server>
4. update pom.xml in GIT and commit the changes
from: <distributionManagement> <snapshotRepository> <id>nexus</id> <url>http://172.31.15.236:8081/repository/maven-snapshots/</url> </snapshotRepository> <repository> <id>nexus</id> <url>http://172.31.15.236:8081/repository/maven-releases/</url> </repository> </distributionManagement> to: <distributionManagement> <snapshotRepository> <id>deployment</id> <url>http://192.168.0.43:8081/repository/maven-snapshots/</url> </snapshotRepository> <repository> <id>deployment</id> <url>http://192.168.0.43:8081/repository/maven-releases/</url> </repository> </distributionManagement>
5. run the job, you will get output:
............................... Uploaded to deployment: http://192.168.0.43:8081/repository/maven-snapshots/in/javahome/myweb/0.0.7-SNAPSHOT/myweb-0.0.7-20200915.005745-1.war (1.6 MB at 248 kB/s) Uploading to deployment: http://192.168.0.43:8081/repository/maven-snapshots/in/javahome/myweb/0.0.7-SNAPSHOT/myweb-0.0.7-20200915.005745-1.pom Progress (1): 1.8 kB Uploaded to deployment: http://192.168.0.43:8081/repository/maven-snapshots/in/javahome/myweb/0.0.7-SNAPSHOT/myweb-0.0.7-20200915.005745-1.pom (1.8 kB at 583 B/s) Downloading from deployment: http://192.168.0.43:8081/repository/maven-snapshots/in/javahome/myweb/maven-metadata.xml Uploading to deployment: http://192.168.0.43:8081/repository/maven-snapshots/in/javahome/myweb/0.0.7-SNAPSHOT/maven-metadata.xml Progress (1): 766 B Uploaded to deployment: http://192.168.0.43:8081/repository/maven-snapshots/in/javahome/myweb/0.0.7-SNAPSHOT/maven-metadata.xml (766 B at 339 B/s) Uploading to deployment: http://192.168.0.43:8081/repository/maven-snapshots/in/javahome/myweb/maven-metadata.xml Progress (1): 276 B Uploaded to deployment: http://192.168.0.43:8081/repository/maven-snapshots/in/javahome/myweb/maven-metadata.xml (276 B at 17 B/s) [[1;34mINFO[m] [1m------------------------------------------------------------------------[m [[1;34mINFO[m] [1;32mBUILD SUCCESS[m [[1;34mINFO[m] [1m------------------------------------------------------------------------[m [[1;34mINFO[m] Total time: 01:00 min [[1;34mINFO[m] Finished at: 2020-09-14T20:58:13-04:00 [[1;34mINFO[m] [1m------------------------------------------------------------------------[m Finished: SUCCESS
check on Nexus, you can find the war file has been uploaded:

6. you can update version number in pom.xml to upload again
<groupId>in.javahome</groupId> <artifactId>myweb</artifactId> <packaging>war</packaging> <version>0.0.8-SNAPSHOT</version> <name>my-app</name>
