0
0
Jenkinsdevops~20 mins

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

Choose your learning style9 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.