Upload Maven Artifacts Into Nexus 3

1 minute read

Sometimes you need to upload an artifact into Nexus. With Nexus 2 this was very easy if you had filesystem access or access to the Web UI. In Nexus 3 you are no longer able to access the filesystem and do not have a UI to upload your artifacts. This is why you have to do it using the mvn CLI.

If you have some strangely proxied system where you have ssh access to the machine running Nexus you can also use SSH port forwarding if you are unable to reach the machine directly otherwise.

You need a configuration like this where the user has permission to deploy into your repository.

If that is out of the way you can use the CLI to upload the artifact like so:

Please note that in this case also a different configuration file is used to upload the artifact, to avoid working with the deployment user for normal builds where you want the user only to have read permission.

mvn -s ~/.m2/settings.xml.upload deploy:deploy-file \
    -DgroupId=org.wildfly \
    -DartifactId=wildfly-dist \
    -Dversion=10.0.0.Final \
    -DgeneratePom=true \
    -Dpackaging=tar.gz \
    -DrepositoryId=repo \
    -Durl=http://repo.example.com/repository/thirdparty \
    -Dfile=wildfly-10.0.0.Final.tar.gz

Updated: