Everyone uses Maven. But sometimes you don’t have the privilege of starting a new Maven project with fancy pom file – Maybe it’s because you’re exporting from Eclipse, maybe you have an existing project with different build tools etc…
For example I have a some Liferay plugins SDK projects that’s already using ANT. If you don’t know what is Liferay, you should check it out, it’s a nice open source, full-fledged JAVA content management system for enterprise websites.
So my developers are using ANT to build their plugin artifacts and I need to store these artifacts (mainly JARS and WARS) in Nexus OSS repository. So I came across the “deploy” maven plugin with its “deploy-file” goal (deploy:deploy-file). It allows you to quickly upload any WAR/JAR file to a maven repository without having to build a complete POM file with millions of dependencies. You can include a pom.xml file if you like and override the properties from the command line.
Make sure you configure your Maven settings.xml file with the Nexus OSS repository credentials like this:
<?xml version="1.0"?> <settings> <servers> <server> <id>liferay-releases</id> <username>admin</username> <password>*****</password> </server> <server> <id>liferay-snapshots</id> <username>admin</username> <password>*****</password> </server> </servers> </settings>
When you execute maven from Jenkins, you need to pass some parameters: (‘properties’)
Notice I’ve used parameter $JOB_NAME to pass the Jenkins job name as an artifact ID + $BUILD_NUMBER as maven version to Nexus OSS.
Finally you get this nice view in Nexus OSS UI after each build: