0
0
Jenkinsdevops~10 mins

External artifact repositories (Nexus, Artifactory) in Jenkins - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - External artifact repositories (Nexus, Artifactory)
Build Project
Package Artifact
Upload Artifact to Repository
Artifact Stored in Nexus/Artifactory
Other Jobs Download Artifact
Deploy or Use Artifact
This flow shows how Jenkins builds a project, packages it, uploads the artifact to an external repository like Nexus or Artifactory, and then other jobs can download and use it.
Execution Sample
Jenkins
pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        sh 'mvn clean package'
      }
    }
    stage('Publish') {
      steps {
        nexusArtifactUploader artifacts: [[artifactId: 'app', file: 'target/app.jar', type: 'jar']],
          credentialsId: 'nexus-creds',
          groupId: 'com.example',
          nexusUrl: 'http://nexus.example.com',
          repository: 'maven-releases',
          version: '1.0.0'
      }
    }
  }
}
This Jenkins pipeline builds a Maven project and uploads the resulting jar artifact to a Nexus repository.
Process Table
StepActionCommand/PluginResultNotes
1Build projectsh 'mvn clean package'target/app.jar createdMaven compiles and packages the app
2Prepare artifact infoDefine artifactId, file, typeArtifact details readyNeeded for upload plugin
3Upload artifactnexusArtifactUploader pluginArtifact uploaded to NexusStored in 'maven-releases' repo
4Verify uploadCheck Nexus UI or APIArtifact visible in repositoryArtifact ready for other jobs
5Download artifactOther Jenkins jobs use 'mvn dependency:get' or curlArtifact retrievedUsed for deployment or testing
6EndN/AProcess completeArtifact lifecycle finished
💡 All steps complete; artifact successfully stored and ready for use
Status Tracker
VariableStartAfter BuildAfter UploadFinal
artifactFilenulltarget/app.jartarget/app.jartarget/app.jar
artifactIdnullappappapp
versionnull1.0.01.0.01.0.0
uploadStatusnot startednot startedsuccesssuccess
Key Moments - 3 Insights
Why does the artifact file path need to be exact in the upload step?
Because the upload plugin uses the file path to find the artifact. If the path is wrong, the upload fails. See execution_table step 3 where 'target/app.jar' is specified.
What happens if the credentials for Nexus are incorrect?
The upload will fail with an authentication error. The pipeline will stop at step 3 in the execution_table because it cannot connect to Nexus.
How do other Jenkins jobs get the artifact after upload?
They download it from Nexus using tools like Maven or curl, as shown in step 5 of the execution_table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the artifact file name after the build step?
Aapp.jar
Btarget/app.jar
Capp-1.0.0.jar
Dartifact.jar
💡 Hint
Check the 'Result' column in step 1 of the execution_table.
At which step does the artifact become available in the Nexus repository?
AStep 4
BStep 2
CStep 3
DStep 5
💡 Hint
Look for the step where the artifact is confirmed visible in the repository.
If the 'version' variable changed to '1.0.1', what would change in the execution_table?
AThe artifact file path would change
BThe upload step would fail
CThe version in the upload details would be '1.0.1'
DNo change at all
💡 Hint
Check the 'version' variable in variable_tracker and how it is used in the upload step.
Concept Snapshot
External artifact repositories store build outputs for reuse.
Jenkins builds and packages artifacts, then uploads them using plugins.
Artifacts are stored with groupId, artifactId, version, and repository info.
Other jobs download artifacts from Nexus or Artifactory for deployment.
Correct file paths and credentials are essential for upload success.
Full Transcript
This visual execution shows how Jenkins interacts with external artifact repositories like Nexus or Artifactory. First, Jenkins builds the project and creates an artifact file, such as a jar. Then it prepares artifact details including artifactId and version. Using a plugin like nexusArtifactUploader, Jenkins uploads the artifact to the repository. After upload, the artifact is visible and stored in Nexus. Other Jenkins jobs can then download this artifact for deployment or testing. Variables like artifactFile and version track the artifact state. Key points include ensuring the file path is correct and credentials are valid. The execution table traces each step from build to upload and verification, helping beginners see the process clearly.