<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jakub Kośla</title>
    <description>The latest articles on DEV Community by Jakub Kośla (@jkosla).</description>
    <link>https://dev.to/jkosla</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2030806%2F31511e0e-466c-43e5-baba-beefb8bb2974.jpg</url>
      <title>DEV Community: Jakub Kośla</title>
      <link>https://dev.to/jkosla</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jkosla"/>
    <language>en</language>
    <item>
      <title>A Complete Guide to Setting Up Nexus (2 Ways) + How to Connect Nexus to Jenkins</title>
      <dc:creator>Jakub Kośla</dc:creator>
      <pubDate>Mon, 06 Jan 2025 13:02:06 +0000</pubDate>
      <link>https://dev.to/jkosla/a-complete-guide-to-setting-up-nexus-2-ways-how-to-connect-nexus-to-jenkins-34c9</link>
      <guid>https://dev.to/jkosla/a-complete-guide-to-setting-up-nexus-2-ways-how-to-connect-nexus-to-jenkins-34c9</guid>
      <description>&lt;h2&gt;
  
  
  🚀 Setting Up Nexus Repository Manager
&lt;/h2&gt;




&lt;h2&gt;
  
  
  📦 What is Nexus?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Nexus is an artifact repository&lt;/strong&gt;, which helps to store artifacts like packages, compiled binaries, Maven files, etc. While developing software, it is a good idea to track such things; it helps to control access and deployment of every artifact in your software from a single location.&lt;/p&gt;




&lt;h2&gt;
  
  
  💡 Why Integrate Nexus with Jenkins?
&lt;/h2&gt;

&lt;p&gt;Manually uploading artifacts to Nexus is &lt;strong&gt;inefficient and prone to errors.&lt;/strong&gt; Integrating Nexus with CI/CD pipelines like Jenkins automates this process, ensuring a &lt;strong&gt;seamless and reliable workflow&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  📝 Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before starting, ensure your system meets the following requirements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;RAM&lt;/strong&gt;: Minimum 8GB&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CPU&lt;/strong&gt;: At least 4 cores&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Java&lt;/strong&gt;: OpenJDK 17 (or the version required by the latest Nexus release)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;System requirements for Nexus depend on your needs and project size. &lt;br&gt;
👉 Detailed system requirements: &lt;a href="https://help.sonatype.com/repomanager3/system-requirements" rel="noopener noreferrer"&gt;Nexus System Requirements&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  ⚙️ Setting Up Nexus
&lt;/h2&gt;

&lt;p&gt;This tutorial demonstrates two methods to set up Nexus on an Ubuntu virtual machine:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;As a systemd service&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Using Docker&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  🛠️ Method 1: Setting Up Nexus as Systemd Service
&lt;/h3&gt;

&lt;p&gt;For this tutorial &lt;strong&gt;I used Java 17&lt;/strong&gt;, but you should check what Java version is required right now &lt;a href="https://help.sonatype.com/en/download.html#download-sonatype-nexus-repository" rel="noopener noreferrer"&gt;here&lt;/a&gt;. Also you need to have sudo privileges.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 1: Install Java
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Update the Package index&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update

&lt;span class="c"&gt;# Install OpenJDK 17&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;openjdk-17-jdk &lt;span class="nt"&gt;-y&lt;/span&gt;

&lt;span class="c"&gt;# Verify the Installation&lt;/span&gt;
java &lt;span class="nt"&gt;-version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Expected output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;azureuser@Nexus:~&lt;span class="nv"&gt;$ &lt;/span&gt;java &lt;span class="nt"&gt;-version&lt;/span&gt;
openjdk version &lt;span class="s2"&gt;"17.0.13"&lt;/span&gt; 2024-10-15
OpenJDK Runtime Environment &lt;span class="o"&gt;(&lt;/span&gt;build 17.0.13+11-Ubuntu-2ubuntu124.04&lt;span class="o"&gt;)&lt;/span&gt;
OpenJDK 64-Bit Server VM &lt;span class="o"&gt;(&lt;/span&gt;build 17.0.13+11-Ubuntu-2ubuntu124.04, mixed mode, sharing&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Step 2: Download and Install Nexus
&lt;/h3&gt;

&lt;p&gt;Here, we will download the Nexus repository and create a specific user to run Nexus as a Systemd service securely. The current version download link is accessible &lt;a href="https://help.sonatype.com/en/download.html#download-sonatype-nexus-repository" rel="noopener noreferrer"&gt;here&lt;/a&gt;. For Linux, choose the Unix Archive.&lt;/p&gt;

&lt;p&gt;1.&lt;strong&gt;Download Nexus&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Change to /opt Directory&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; /opt

&lt;span class="c"&gt;# Download Nexus Artifact Repository&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;wget https://download.sonatype.com/nexus/3/nexus-3.75.1-01-unix.tar.gz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;2.➕ &lt;strong&gt;(Optional) Verify MD5 Checksum&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;md5sum &lt;/span&gt;nexus-3.75.1-01-unix.tar.gz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Compare the output with the checksum provided on the &lt;a href="https://download.sonatype.com/nexus/3/nexus-3.75.1-01-unix.tar.gz.md5" rel="noopener noreferrer"&gt;official site&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;3.&lt;strong&gt;Extract and Rename Nexus&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Extract the downloaded file&lt;/span&gt;
&lt;span class="nb"&gt;sudo tar&lt;/span&gt; &lt;span class="nt"&gt;-zxvf&lt;/span&gt; nexus-3.75.1-01-unix.tar.gz 

&lt;span class="c"&gt;# Rename for convenience&lt;/span&gt;
&lt;span class="nb"&gt;sudo mv &lt;/span&gt;nexus-3.75.1-01 nexus
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Step 3: Create a Nexus User
&lt;/h3&gt;

&lt;p&gt;Now, as I mentioned earlier we will create a specific user which will be allowed to run Nexus as system service:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Create a dedicated user for Nexus&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;useradd nexus

&lt;span class="c"&gt;# Set a password for the user&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;passwd nexus
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Step 4: Add the User to sudoers
&lt;/h3&gt;

&lt;p&gt;Add the Nexus user to the sudoers file so that they will be able to run Nexus as a service.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Change /etc/sudoers &lt;/span&gt;
&lt;span class="nb"&gt;sudo chmod &lt;/span&gt;755 /etc/sudoers

&lt;span class="c"&gt;# Edit sudoers file&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;vi /etc/sudoers

&lt;span class="c"&gt;# Add this line under "User privilege specification"&lt;/span&gt;
nexus &lt;span class="nv"&gt;ALL&lt;/span&gt;&lt;span class="o"&gt;=(&lt;/span&gt;ALL&lt;span class="o"&gt;)&lt;/span&gt; NOPASSWD:ALL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Step 5: Configure Permissions
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Change ownership of Nexus directories&lt;/span&gt;
&lt;span class="nb"&gt;sudo chown&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; nexus:nexus /opt/nexus
&lt;span class="nb"&gt;sudo chown&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; nexus:nexus /opt/sonatype-work

&lt;span class="c"&gt;# Set the user to run Nexus&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;vi /opt/nexus/bin/nexus.rc
&lt;span class="c"&gt;# Uncomment and set:&lt;/span&gt;
&lt;span class="nv"&gt;run_as_user&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"nexus"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Step 6: Create a Systemd Service
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Create a systemd unit file&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;vi /etc/systemd/system/nexus.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Insert the following:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;Unit]
&lt;span class="nv"&gt;Description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;Nexus Service
&lt;span class="nv"&gt;After&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;network.target

&lt;span class="o"&gt;[&lt;/span&gt;Service]
&lt;span class="nv"&gt;Type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;forking
&lt;span class="nv"&gt;LimitNOFILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;65536
&lt;span class="nv"&gt;ExecStart&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/opt/nexus/bin/nexus start
&lt;span class="nv"&gt;ExecStop&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/opt/nexus/bin/nexus stop
&lt;span class="nv"&gt;User&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;nexus
&lt;span class="nv"&gt;Restart&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;on-abort

&lt;span class="o"&gt;[&lt;/span&gt;Install]
&lt;span class="nv"&gt;WantedBy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;multi-user.target
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Step 7: Start Nexus Service
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Reload systemd and start Nexus&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl daemon-reload
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl start nexus

&lt;span class="c"&gt;# Enable Nexus to start on boot&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;nexus

&lt;span class="c"&gt;# Check Nexus service status&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl status nexus
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Expected output:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl status nexus
● nexus.service - nexus service
     Loaded: loaded &lt;span class="o"&gt;(&lt;/span&gt;/etc/systemd/system/nexus.service&lt;span class="p"&gt;;&lt;/span&gt; enabled&lt;span class="p"&gt;;&lt;/span&gt; preset: enabled&lt;span class="o"&gt;)&lt;/span&gt;
     Active: active &lt;span class="o"&gt;(&lt;/span&gt;running&lt;span class="o"&gt;)&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🐳 Method 2: Using Docker
&lt;/h3&gt;

&lt;p&gt;Installing Nexus with Docker is &lt;strong&gt;significantly easier and less complicated&lt;/strong&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 1: Install Docker
&lt;/h3&gt;

&lt;p&gt;If Docker is not installed, follow the &lt;a href="https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository" rel="noopener noreferrer"&gt;official Docker installation guide&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 2: Run Nexus Container
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Pull the Nexus Docker image&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;docker pull sonatype/nexus3

&lt;span class="c"&gt;# Run the Nexus container&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 8081:8081 &lt;span class="nt"&gt;--name&lt;/span&gt; nexus sonatype/nexus3

&lt;span class="c"&gt;# Verify the container is running&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;docker ps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Expected output:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;azureuser@Nexus:~&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;docker ps
CONTAINER ID   IMAGE             COMMAND                  CREATED         STATUS         PORTS                                       NAMES
1a7bddff88b5   sonatype/nexus3   &lt;span class="s2"&gt;"/opt/sonatype/nexus…"&lt;/span&gt;   2 minutes ago   Up 2 minutes   0.0.0.0:8081-&amp;gt;8081/tcp, :::8081-&amp;gt;8081/tcp   nexus
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🌐 Accessing Nexus
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Step 1: Open a web browser and navigate to: &lt;code&gt;http://&amp;lt;your-server-ip&amp;gt;:8081&lt;/code&gt;
&lt;/h3&gt;
&lt;h3&gt;
  
  
  Step 2: Sign in with the default credentials:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Username&lt;/strong&gt;: admin&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Password&lt;/strong&gt;: Found in:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/opt/sonatype-work/nexus3/admin.password&lt;/code&gt; (systemd)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/nexus-data/admin.password&lt;/code&gt; (Docker)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Retrieve the password:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# For systemd setup&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; /opt/sonatype-work/nexus3/admin.password

&lt;span class="c"&gt;# For Docker setup&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;docker &lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; nexus /bin/bash &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"cat /nexus-data/admin.password"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Step 3: First sign in
&lt;/h3&gt;

&lt;p&gt;You will be promoted by setup window wizard that will help you to complete required setup tasks, click next.&lt;/p&gt;

&lt;p&gt;And change the password:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft0qwgsz70zetmyl4zajf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft0qwgsz70zetmyl4zajf.png" alt="Password Change" width="696" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then configure anonymous access. You can enable or disable anonymous access. Choose what matches you needs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm4sqhzpvzk7h92y4puml.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm4sqhzpvzk7h92y4puml.png" alt="Anonymous access choose" width="690" height="342"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  📂 Creating a Nexus Repository
&lt;/h2&gt;

&lt;p&gt;Signed in as admin, click the gear icon on the upper toolbar. Then, on the left, click &lt;strong&gt;Repositories&lt;/strong&gt;, and you should see the &lt;strong&gt;Create Repository&lt;/strong&gt; button.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnlhhfnmv4ln44i39472n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnlhhfnmv4ln44i39472n.png" alt="Create repository" width="800" height="265"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Choose the type of repository you want. You can read more about them &lt;a href="https://help.sonatype.com/en/formats.html" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For this tutorial, I will go with the &lt;code&gt;raw&lt;/code&gt; repository, where &lt;strong&gt;I will upload .txt files&lt;/strong&gt;. Then, set up the repository by naming it and selecting the options you need. Finally, click &lt;strong&gt;Create Repository&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3p7e0wun0j0fmy1sipu6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3p7e0wun0j0fmy1sipu6.png" alt="Repository settings" width="800" height="943"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you should be able to see your repository on the dashboard. Click the cube icon next to the gear icon, then browse and look for your new repository. Click on it to see its contents.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F30go153f0owdlieinyqy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F30go153f0owdlieinyqy.png" alt="Reposiotry Contents" width="800" height="174"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, you can manually upload files to the repository, but it's inefficient. That's why we will use Jenkins for this 🔽🔽🔽&lt;/p&gt;


&lt;h2&gt;
  
  
  🔗 Connecting Nexus to Jenkins
&lt;/h2&gt;

&lt;p&gt;I have a simple &lt;a href="https://github.com/jkosla/nexus-tutorial" rel="noopener noreferrer"&gt;repository&lt;/a&gt; connected with Jenkins. I will upload the file &lt;strong&gt;requirements.txt&lt;/strong&gt; to &lt;strong&gt;Nexus&lt;/strong&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 1: Creating a Jenkins User in Nexus
&lt;/h3&gt;

&lt;p&gt;You need to identify the user that is trying to push artifacts to the repository. Therefore, we need to add a Jenkins user in the Nexus repository. &lt;strong&gt;These credentials will be used in Jenkins&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzpadmsj9jfs3njh6y1l6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzpadmsj9jfs3njh6y1l6.png" alt="nexus create user" width="800" height="562"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 2: Installing the Nexus Plugin in Jenkins
&lt;/h3&gt;

&lt;p&gt;The first thing you need to do is install the &lt;a href="https://plugins.jenkins.io/nexus-artifact-uploader/" rel="noopener noreferrer"&gt;Nexus Plugin&lt;/a&gt;. Go to &lt;strong&gt;Manage Jenkins&lt;/strong&gt; &amp;gt; &lt;strong&gt;Plugins&lt;/strong&gt;. Type &lt;code&gt;Nexus,&lt;/code&gt; and you will see the&lt;code&gt;Nexus Artifact Uploader&lt;/code&gt;. Check it and click Install.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdjc0nvqg06hil07ep3jr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdjc0nvqg06hil07ep3jr.png" alt="nexus plugin" width="800" height="210"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 3: Adding Nexus Credentials to Jenkins
&lt;/h3&gt;

&lt;p&gt;In Jenkins, we need to add credentials. &lt;br&gt;
🔑 &lt;strong&gt;Key Point&lt;/strong&gt;: Use the same username and password in Jenkins as created in Nexus for seamless integration&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fccrj5u58nd7qng9qmzwx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fccrj5u58nd7qng9qmzwx.png" alt="Jenkins add Credentials" width="724" height="879"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 4: Adding a Jenkinsfile
&lt;/h3&gt;

&lt;p&gt;Finally, in your code repository, add a &lt;code&gt;Jenkinsfile&lt;/code&gt; that includes a stage for uploading to Nexus, structured as follows:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;You can specify the values as you wish and adjust the following parameters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;artifactId&lt;/code&gt;: The ID of the artifact you want to upload.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;file&lt;/code&gt;: The path to the &lt;strong&gt;artifact you want to upload&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;type&lt;/code&gt;: The type of artifact.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;credentialsId&lt;/code&gt;: 🔑 &lt;strong&gt;Key Point&lt;/strong&gt; Use the credentials ID you named in Jenkins.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;groupId&lt;/code&gt;: Specify as you wish; this will create the corresponding folder structure in the Nexus repository.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;nexusUrl&lt;/code&gt;: The URL or IP address of your Nexus repository.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;repository&lt;/code&gt;: The name of the repository.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  ✅ Integration Check
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Trigger Pipeline&lt;/strong&gt;&lt;br&gt;
Update a file (e.g., &lt;code&gt;requirements.txt&lt;/code&gt;) and push changes to trigger the Jenkins pipeline.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuy1zhtqfqr402sqr344h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuy1zhtqfqr402sqr344h.png" alt="Update requirements.txt" width="800" height="223"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can see that Jenkins was triggered and the upload to Nexus was successful.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw3s97lu679prgoa8j70g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw3s97lu679prgoa8j70g.png" alt="Jenkins success build" width="800" height="269"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Verify Upload&lt;/strong&gt;&lt;br&gt;
Navigate to your Nexus repository and confirm the artifact is uploaded.&lt;br&gt;
Now we see that &lt;code&gt;requirements.txt&lt;/code&gt; has been added to the repository with the correct path.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Freav2andcky6wutwlyt7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Freav2andcky6wutwlyt7.png" alt="Nexus success upload" width="752" height="363"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🙌 &lt;strong&gt;This concludes the tutorial. Thank you!&lt;/strong&gt; 🙌&lt;/p&gt;

&lt;p&gt;Feel free to leave any questions you have in the comments below! 💬 I'm here to help! 😊&lt;/p&gt;

&lt;h2&gt;
  
  
  📚 Official Docs
&lt;/h2&gt;

&lt;p&gt;✨ &lt;a href="https://help.sonatype.com/en/sonatype-nexus-repository.html" rel="noopener noreferrer"&gt;Nexus Documentation&lt;/a&gt;&lt;br&gt;
✨ &lt;a href="https://www.jenkins.io/doc/" rel="noopener noreferrer"&gt;Jenkins Documentation&lt;/a&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>jenkins</category>
    </item>
  </channel>
</rss>
