Reputation: 441
Context : I do not have UI access to Nexus Repository but I have access to Jenkins configured with access to nexus repository. I have a shaded jar in my git repository which needs to be directly uploaded to nexus repository using maven without pom.xml or settings.xml file.
Problem : How to upload a jar in git repo to nexus repository using Jenkins with maven plugin ?
I tried searching for this specific usecase and was not able to find a solution.
Upvotes: 3
Views: 11590
Reputation: 441
You can create a Jenkins Job to clone git repository [Source Code Management] where the required jar is present and configure Jenkins Job Build stage with below maven command [Execute Shell] :
mvn deploy:deploy-file \
-DgroupId=com.example.test \
-DartifactId=test-module \
-Dversion=1.0.0 \
-DgeneratePom=true \
-Dpackaging=jar \
-DrepositoryId=sample-rel \
-Durl=http://nexus.private.net/Your_Nexus_Repository_Path \
-Dfile=./PATH_TO_JAR_FILE
(edit: multi-line for legibility)
Upvotes: 5
Reputation: 5318
The deploy:deploy-file solution above still requires a settings.xml file. The login credentials will be retrieved from the setting.xml "servers" section using the ID specified in the repositoryId parameter. There isn't any way that I know of to deploy using Maven without a settings.xml file. But you can specify a custom settings.xml file with "mvn -s some/path/settings.xml".
Alternatively, you could use a Jenkins plugin to do the deploy: https://help.sonatype.com/integrations/nexus-and-continuous-integration/nexus-platform-plugin-for-jenkins#NexusPlatformPluginforJenkins-RepositoryManager3Integration
Upvotes: 1