Bird
Raised Fist0
Jenkinsdevops~20 mins

External artifact repositories (Nexus, Artifactory) in Jenkins - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Artifact Repository Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Jenkins Pipeline: Upload artifact to Nexus
What will be the output of this Jenkins pipeline snippet when uploading a file to Nexus repository?
Jenkins
pipeline {
  agent any
  stages {
    stage('Upload') {
      steps {
        script {
          sh '''
          curl -v -u admin:admin123 --upload-file myapp.jar \
          http://nexus.example.com/repository/maven-releases/com/example/myapp/1.0/myapp-1.0.jar
          '''
        }
      }
    }
  }
}
AUpload succeeds with HTTP 201 Created status and artifact stored in Nexus
BUpload fails with HTTP 404 Not Found because repository URL is incorrect
CUpload fails with HTTP 401 Unauthorized due to wrong credentials
DUpload succeeds but artifact is stored in Nexus with a wrong version number
Attempts:
2 left
💡 Hint
Check the HTTP status code returned by curl and the repository URL correctness.
❓ Troubleshoot
intermediate
2:00remaining
Artifact download failure from Artifactory
A Jenkins job tries to download an artifact from Artifactory using this command: curl -u user:pass -O http://artifactory.example.com/artifactory/libs-release-local/com/example/app/1.0/app-1.0.jar The job fails with '404 Not Found'. What is the most likely cause?
AThe curl command syntax is invalid and causes failure
BThe artifact path or version does not exist in Artifactory
CThe Artifactory server is down and not reachable
DThe user credentials are incorrect causing access denial
Attempts:
2 left
💡 Hint
404 means the resource was not found at the URL.
❓ Configuration
advanced
3:00remaining
Jenkins Declarative Pipeline with Artifactory integration
Which Jenkins pipeline snippet correctly configures Artifactory server and uploads a Maven artifact using the Artifactory plugin?
A
pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        rtMavenDeployer(
          id: 'deployer-1',
          releaseRepo: 'libs-release-local',
          snapshotRepo: 'libs-snapshot-local'
        )
        rtMavenRun(
          pom: 'pom.xml',
          goals: 'clean install'
        )
      }
    }
  }
}
B
pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        rtMavenDeployer(
          id: 'deployer-1',
          serverId: 'wrong-server',
          releaseRepo: 'libs-release-local',
          snapshotRepo: 'libs-snapshot-local'
        )
        rtMavenRun(
          pom: 'pom.xml',
          goals: 'clean install'
        )
      }
    }
  }
}
C
pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        rtMavenDeployer(
          id: 'deployer-1',
          serverId: 'artifactory-server',
          releaseRepo: 'libs-release-local',
          snapshotRepo: 'libs-snapshot-local'
        )
        rtMavenRun(
          pom: 'pom.xml',
          goals: 'clean install'
        )
      }
    }
  }
}
D
pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        rtMavenDeployer(
          id: 'deployer-1',
          serverId: 'artifactory-server',
          releaseRepo: 'libs-release-local'
        )
        rtMavenRun(
          pom: 'pom.xml',
          goals: 'clean install'
        )
      }
    }
  }
}
Attempts:
2 left
💡 Hint
The serverId must match the configured Artifactory server in Jenkins.
✅ Best Practice
advanced
2:00remaining
Secure handling of credentials for Nexus in Jenkins
Which method is the best practice to securely use Nexus credentials in a Jenkins pipeline?
AStore credentials in Jenkins Credentials Manager and reference them with 'credentialsId' in pipeline
BHardcode username and password directly in the pipeline script for simplicity
CStore credentials in a plain text file on the Jenkins master and read it during the build
DUse environment variables set globally on Jenkins master without encryption
Attempts:
2 left
💡 Hint
Think about security and ease of credential management.
🔀 Workflow
expert
4:00remaining
Automated artifact versioning and deployment workflow with Jenkins and Artifactory
Which Jenkins pipeline workflow correctly implements automatic semantic versioning and uploads the artifact to Artifactory with the new version?
Jenkins
pipeline {
  agent any
  environment {
    ARTIFACTORY_SERVER = 'artifactory-server'
  }
  stages {
    stage('Versioning') {
      steps {
        script {
          def version = sh(script: "git describe --tags --abbrev=0", returnStdout: true).trim()
          def parts = version.tokenize('.')
          def patch = parts[2].toInteger() + 1
          env.NEW_VERSION = "${parts[0]}.${parts[1]}.${patch}"
          echo "New version: ${env.NEW_VERSION}"
        }
      }
    }
    stage('Build and Upload') {
      steps {
        rtMavenDeployer(
          id: 'deployer-1',
          serverId: ARTIFACTORY_SERVER,
          releaseRepo: 'libs-release-local'
        )
        rtMavenRun(
          pom: 'pom.xml',
          goals: "clean install -Drevision=${env.NEW_VERSION}"
        )
      }
    }
  }
}
AThe pipeline fails because git describe command is missing in Jenkins environment
BThe pipeline uses fixed version from pom.xml and uploads artifact without version change
CThe pipeline increments major version incorrectly causing build failure
DThe pipeline increments patch version from last git tag, sets it as Maven revision, and uploads artifact to Artifactory
Attempts:
2 left
💡 Hint
Check how the version is parsed and incremented, and how it is passed to Maven build.

Practice

(1/5)
1. What is the main purpose of using external artifact repositories like Nexus or Artifactory in Jenkins pipelines?
easy
A. To monitor Jenkins job execution times
B. To run Jenkins jobs faster by caching source code
C. To replace Jenkins as a build server
D. To store and share build artifacts for reuse in other projects

Solution

  1. Step 1: Understand artifact repositories role

    Artifact repositories store build outputs like binaries or libraries for reuse.
  2. Step 2: Connect to Jenkins pipeline usage

    Jenkins uploads artifacts to these repositories to share with other projects or teams.
  3. Final Answer:

    To store and share build artifacts for reuse in other projects -> Option D
  4. Quick Check:

    Artifact repositories = store and share artifacts [OK]
Hint: Artifact repos store build outputs for sharing [OK]
Common Mistakes:
  • Confusing artifact repos with build servers
  • Thinking they speed up job execution directly
  • Assuming they monitor Jenkins jobs
2. Which Jenkins plugin is commonly used to upload artifacts to a Nexus repository?
easy
A. Nexus Artifact Uploader
B. Git Plugin
C. Docker Pipeline
D. Slack Notification

Solution

  1. Step 1: Identify plugins for artifact upload

    The Nexus Artifact Uploader plugin is designed to upload build artifacts to Nexus repositories.
  2. Step 2: Exclude unrelated plugins

    Git Plugin manages source code, Docker Pipeline manages containers, Slack Notification sends messages.
  3. Final Answer:

    Nexus Artifact Uploader -> Option A
  4. Quick Check:

    Nexus upload plugin = Nexus Artifact Uploader [OK]
Hint: Nexus upload uses Nexus Artifact Uploader plugin [OK]
Common Mistakes:
  • Choosing Git Plugin for artifact upload
  • Confusing Docker Pipeline with artifact upload
  • Selecting notification plugins by mistake
3. Given this Jenkins pipeline snippet using Artifactory plugin:
artifactoryServer.upload spec: '''{
  "files": [
    {"pattern": "build/libs/*.jar", "target": "libs-release-local/"}
  ]
}'''

What does this code do?
medium
A. Uploads all JAR files from build/libs to libs-release-local repository
B. Downloads JAR files from libs-release-local to build/libs
C. Deletes JAR files from build/libs directory
D. Builds JAR files inside the Jenkins workspace

Solution

  1. Step 1: Analyze the upload spec JSON

    The spec says to upload files matching build/libs/*.jar to target libs-release-local/ repository.
  2. Step 2: Understand Artifactory plugin upload method

    upload method sends files from Jenkins workspace to the external repository location.
  3. Final Answer:

    Uploads all JAR files from build/libs to libs-release-local repository -> Option A
  4. Quick Check:

    upload spec = upload files to repo [OK]
Hint: Upload spec means send files to repo path [OK]
Common Mistakes:
  • Confusing upload with download
  • Thinking it deletes files
  • Assuming it builds artifacts
4. You configured Jenkins to upload artifacts to Nexus but the upload fails with authentication error. What is the most likely cause?
medium
A. Build artifacts are missing in workspace
B. Incorrect repository URL configured in Jenkins
C. Missing or wrong credentials for Nexus repository in Jenkins
D. Jenkins server is offline

Solution

  1. Step 1: Understand authentication error meaning

    Authentication errors usually mean Jenkins cannot log in to Nexus due to bad credentials.
  2. Step 2: Check common causes

    Incorrect URL causes connection errors, missing artifacts cause upload failure but not auth error, offline server causes connection failure.
  3. Final Answer:

    Missing or wrong credentials for Nexus repository in Jenkins -> Option C
  4. Quick Check:

    Auth error = bad credentials [OK]
Hint: Auth errors mean check credentials first [OK]
Common Mistakes:
  • Assuming URL is always the cause
  • Ignoring credentials setup
  • Confusing missing files with auth errors
5. You want to configure a Jenkins pipeline to upload a Docker image to Artifactory and also store the build logs as an artifact. Which two configurations are essential?
hard
A. Configure Git repository URL; use 'docker build' only
B. Configure Artifactory Docker registry URL and credentials; use 'archiveArtifacts' step for logs
C. Use 'sh' step to upload logs manually; no credentials needed
D. Configure Jenkins email notifications; use 'stash' for Docker images

Solution

  1. Step 1: Identify Docker image upload requirements

    Uploading Docker images to Artifactory requires setting the Docker registry URL and credentials in Jenkins.
  2. Step 2: Identify artifact storage for logs

    Jenkins 'archiveArtifacts' step stores build logs or files as artifacts for later access.
  3. Final Answer:

    Configure Artifactory Docker registry URL and credentials; use 'archiveArtifacts' step for logs -> Option B
  4. Quick Check:

    Docker upload + archive logs = config URL/creds + archiveArtifacts [OK]
Hint: Docker upload needs registry + creds; logs need archiveArtifacts [OK]
Common Mistakes:
  • Confusing Git URL with Docker registry URL
  • Skipping credentials for Artifactory
  • Using stash instead of archiveArtifacts for logs
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard