Simple maven deploy with credentials as arguments

If you don’t code day to day in some JVM language but you still need to use Maven for deploying artifacts from time to time, your best option is to use Maven docker image. However, credentials to your Maven repository are stored in .m2/settings.xml in your home folder which makes the standard Maven docker image harder to use.

If you just want to deploy an artifact, you can use image raget/maven-deployer.

docker pull raget/maven-deployer

It is pretty easy:

docker run -v <path_to_artefacts_folder>:/data mvn-deploy "-Drepo.id=<YOUR_REPO>"
 "-Drepo.login=<YOUR_USERNAME>" "-Drepo.pwd=<YOUR_PASSWORD>" "-Dfile=/data/artifact.zip"

Sometimes it is hard to remember all those parameters for maven deploy, so here it is:

docker run -v <path_to_artefacts_folder>:/data mvn-deploy "-Drepo.id=<YOUR_REPO>"
 "-Drepo.login=<YOUR_USERNAME>" "-Drepo.pwd=<YOUR_PASSWORD>"
 "-DgroupId=com.company.product" "-DartifactId=com.company.product.artifact"
 "-Dversion=1.0.0.0" "-Dpackaging=zip" "-Dfile=/data/artifact.zip"
 "-DrepositoryId=company-releases" "-Durl=http://repo.company.com/content/repositories/releases/"

Check out the code at https://github.com/raget/maven-deployer and docker image at https://hub.docker.com/repository/docker/raget/maven-deployer.

Leave a Reply

Your email address will not be published. Required fields are marked *