I just want to archive the latest jar, while keeping version on the jar.
In my pom I have the
<finalName>${project.name}-${project.version}</finalName>
Which dynamically changes version. But when I have Jenkins archive target/**.jar, it archives every old build. Is there a way to only archive the latest version? I tried to see if I could use the POM's maven variables, but it didn't look like I could.
You may just the following command
mvn clean package
instead of
mvn package
It will remove all artifacts and previous compiled classes. So, Jenkins won't upload all jars in you repo.
You could also rune the following command, that only require maven configuration (Jenkins independant)
mvn clean deploy
This will indeed push your maven artifacts into your local repo (like install) and then into you main / corporate repo. It require more configuration (pom.xml > repositories, distribution management, settings.xml > accounts / credentials.
Take a lool here :
This is the right way to do what you want to achieve.