{"id":442,"date":"2021-05-08T15:00:00","date_gmt":"2021-05-08T15:00:00","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/2015\/10\/19\/how-to-upload-the-artifacts-in-sonatype-nexus\/"},"modified":"2021-10-28T05:54:50","modified_gmt":"2021-10-28T05:54:50","slug":"how-to-upload-the-artifacts-in-sonatype-nexus","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/how-to-upload-the-artifacts-in-sonatype-nexus\/","title":{"rendered":"How to upload the artifacts in Sonatype Nexus using Maven"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Step 1 &#8211; Install and Configure Nexus Server<\/h2>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-devopsschool-com wp-block-embed-devopsschool-com\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"qmIT9iU24i\"><a href=\"https:\/\/www.devopsschool.com\/blog\/how-to-install-and-configure-sonatype-nexus\/\">How to install and configure Sonatype Nexus?<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;How to install and configure Sonatype Nexus?&#8221; &#8212; \" src=\"https:\/\/www.devopsschool.com\/blog\/how-to-install-and-configure-sonatype-nexus\/embed\/#?secret=v2aigXFoKv#?secret=qmIT9iU24i\" data-secret=\"qmIT9iU24i\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2 &#8211; [Nexus Server] Create a nexus role containing all required access of Nexus.<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"915\" height=\"620\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2021\/05\/nexus-create-role.jpg\" alt=\"\" class=\"wp-image-21277\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2021\/05\/nexus-create-role.jpg 915w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2021\/05\/nexus-create-role-300x203.jpg 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2021\/05\/nexus-create-role-768x520.jpg 768w\" sizes=\"auto, (max-width: 915px) 100vw, 915px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3 &#8211; [Nexus Server] Create a user which must be used for package deployment by maven to Nexus. user must be added to Role.<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"950\" height=\"612\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2021\/05\/nexus-create-user.jpg\" alt=\"\" class=\"wp-image-21279\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2021\/05\/nexus-create-user.jpg 950w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2021\/05\/nexus-create-user-300x193.jpg 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2021\/05\/nexus-create-user-768x495.jpg 768w\" sizes=\"auto, (max-width: 950px) 100vw, 950px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4 &#8211; [Nexus Server] Login to Nexus using New created user<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5 &#8211; [Nexus Server] Create a 1 repository of Maven 2 type But Policy must be Hosted Release<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">Step 6 &#8211; [Nexus Server] Create a 1 repository of Maven 2 type But Policy must be Hosted Snapshot<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">Step 7 &#8211; [Nexus Server] Create a 1 repository of Maven 2 type But Policy must be Proxy of Maven Central<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">Step 8 &#8211; [Nexus Server] Create a 1 repository of Maven 2 type But Policy must be Group containing all 3 repo created above<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"545\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2021\/05\/nexus-create-repostory-maven-1-1024x545.jpg\" alt=\"\" class=\"wp-image-21275\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2021\/05\/nexus-create-repostory-maven-1-1024x545.jpg 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2021\/05\/nexus-create-repostory-maven-1-300x160.jpg 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2021\/05\/nexus-create-repostory-maven-1-768x409.jpg 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2021\/05\/nexus-create-repostory-maven-1.jpg 1209w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Step 9 &#8211; [Workstation] Download &#8211; Install &#8211; Configure Java and Maven<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">Step 10 &#8211; [Workstation] Create a Maven Sample Project<\/h2>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">$ mvn archetype:generate -DgroupId=com.companyname.devopsschool -DartifactId=chat -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=<span class=\"hljs-literal\">false<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Step 11 &#8211; Modify a pom.xml with a repository where you want to upload a artifact using Maven<\/h2>\n\n\n\n<script src=\"https:\/\/gist.github.com\/devops-school\/4e66a799d3d0138cea8c470e74c9e9b0.js\"><\/script>\n\n\n\n<h2 class=\"wp-block-heading\">Step 12 &#8211; Modify a setting.xml with a repository permission with a new user created<\/h2>\n\n\n\n<script src=\"https:\/\/gist.github.com\/devops-school\/06bb8ddcbf016e91c3dff8e0908b5442.js\"><\/script>\n\n\n\n<h2 class=\"wp-block-heading\">Step 13 &#8211; Important &#8211; repository id in pom.xml(distributionManagement element) and access id in setting.xml (server element) must match.+<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"989\" height=\"534\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2021\/05\/nexus-maven-package-upload.jpg\" alt=\"\" class=\"wp-image-21283\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2021\/05\/nexus-maven-package-upload.jpg 989w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2021\/05\/nexus-maven-package-upload-300x162.jpg 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2021\/05\/nexus-maven-package-upload-768x415.jpg 768w\" sizes=\"auto, (max-width: 989px) 100vw, 989px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Step 14 &#8211; Run maven deploy to upload artifact<\/h2>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># To Upload Snapshot version of Artifact, Make sure pom.xml version element must be with SNAPSHOT<\/span>\n$ mvn deploy\n\n<span class=\"hljs-comment\"># To Upload Releasde version of Artifact, Make sure pom.xml version element must be without SNAPSHOT<\/span>\n$ mvn deploy<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_12148\"><figure class=\"wp-block-embed wp-block-embed-youtube is-type-video is-provider-youtube epyt-figure\"><div class=\"wp-block-embed__wrapper\"><iframe loading=\"lazy\"  id=\"_ytid_68251\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_12148\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><\/div><\/figure><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Step 1 &#8211; Install and Configure Nexus Server Step 2 &#8211; [Nexus Server] Create a nexus role containing all required access of Nexus. Step 3 &#8211; [Nexus Server] Create a user which must be used for package deployment by maven to Nexus. user must be added to Role. Step 4 &#8211; [Nexus Server] Login to&#8230;<\/p>\n","protected":false},"author":1,"featured_media":3075,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[157],"tags":[909,378,545,570,213,908,910],"class_list":["post-442","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sonatype-nexus","tag-artifacts","tag-commands","tag-how","tag-sonatype-nexus","tag-tutorial","tag-upload","tag-upload-artifacts"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/442","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=442"}],"version-history":[{"count":8,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/442\/revisions"}],"predecessor-version":[{"id":24395,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/442\/revisions\/24395"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/3075"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=442"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=442"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}