简体   繁体   中英

How to directly upload a jar file to nexus repository using maven without pom file or settings.xml file?

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.

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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM