Day 74: Nexus Repository Setup

In modern DevOps, artifact management is crucial. Today, I worked on setting up Nexus Repository and integrated it into my Jenkins Pipeline to store versioned build artifacts.


πŸ“Œ Why Nexus Repository?

Nexus is a universal artifact repository manager. It allows us to:
βœ… Store build artifacts (JAR, WAR, Docker images).
βœ… Version control for builds.
βœ… Share artifacts across environments (QA β†’ Staging β†’ Prod).
βœ… Secure access using credentials.


βš™οΈ Jenkins Pipeline with Nexus Integration

Here’s the pipeline I used for nexus setup:

pipeline {
    agent any
    tools {
        maven "MAVEN3"
        jdk "OracleJDK8"
    }
    stages{
       stage("UploadArtifact"){
            steps{
                nexusArtifactUploader(
                  nexusVersion: 'nexus3',
                  protocol: 'http',
                  nexusUrl: '172.31.18.28:8081',
                  groupId: 'QA',
                  version: "${env.BUILD_ID}-${env.BUILD_TIMESTAMP}",
                  repository: 'vprofile-repo',
                  credentialsId: 'nexuslogin',
                  artifacts: [
                    [artifactId: 'vproapp',
                     classifier: '',
                     file: 'target/vprofile-v2.war',
                     type: 'war']
                  ]
                )
            }
        }
    }
}

πŸ› οΈ Breakdown of Nexus Upload Stage

  • nexusArtifactUploader β†’ Jenkins plugin to push artifacts to Nexus.

  • nexusVersion β†’ Specifies Nexus 3.

  • credentialsId β†’ Jenkins credentials for authentication.

  • groupId β†’ Logical group for your artifacts (QA in this case).

  • version β†’ Uses Jenkins build ID + timestamp for versioning.

  • repository β†’ Nexus repo name (vprofile-repo).

  • artifacts β†’ WAR file to upload.


πŸš€ Why This Matters?

  • Every successful build gets uploaded to Nexus.

  • Builds are versioned automatically using Jenkins metadata.

  • QA/Dev teams can fetch exact builds for testing or deployment.

  • Prevents "works on my machine" issues by having one source of truth for artifacts.

0
Subscribe to my newsletter

Read articles from Shaharyar Shakir directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Shaharyar Shakir
Shaharyar Shakir