I am building a development pipeline. The Docker images will be created automatically after a successful and tested version of my java application be deployed on a private Maven repository (Sonatype Nexus).
Once my application is built successfully, I need to publish it in somewhere, and Docker needs to have access to download it and create a container.
I thought on Docker accessing the Nexus Maven repository, but I did not find how can wget
download a jar from a private repository. I did not found on Nexus documentation how I can pass authentication parameters to access a private URL. Does anyone know that?
PS: I also accept advice of easier solutions to accomplish this.
I just discovered I can do it using cURL. Example:
curl -u username:password -o myapp.war "http://nexus.mycompany.com/service/local/artifact/maven/redirect?r=snapshots&g=com.company&a=MyApp&v=1.0-SNAPSHOT&p=war" -L
Where de -L
flag is to cURL accepts redirect (301 response).
So, in docker-compose.yml
I have a line like this:
RUN curl -u username:password -o myapp.war "http://nexus.mycompany.com/service/local/artifact/maven/redirect?r=snapshots&g=com.company&a=MyApp&v=1.0-SNAPSHOT&p=war" -L
If you are using maven
mvn dependency:copy -Dartifact=groupId:artifactId:version[:packaging][:classifier] -DoutputDirectory=[target] -Dusername=[username] -Dpassword=[password]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With