0
0
Jenkinsdevops~10 mins

JDK configuration in Jenkins - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the JDK version in Jenkins pipeline.

Jenkins
pipeline {
  agent any
  tools {
    jdk '[1]'
  }
  stages {
    stage('Build') {
      steps {
        echo 'Building with JDK'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
AJDK8
BJDK14
CJDK7
DJDK11
Attempts:
3 left
💡 Hint
Common Mistakes
Using a JDK version not installed or configured in Jenkins.
Misspelling the JDK name.
2fill in blank
medium

Complete the code to define a JDK tool in Jenkins global configuration using Groovy script.

Jenkins
import jenkins.model.*
import hudson.tools.*

Jenkins.instance.getDescriptorByType(hudson.tools.JDK.DescriptorImpl.class).setInstallations(
  new JDK('[1]', null)
)
Jenkins.instance.save()
Drag options to blanks, or click blank then click option'
AJDK11
BOpenJDK
COracleJDK
DJDK 1.8
Attempts:
3 left
💡 Hint
Common Mistakes
Using names with spaces which Jenkins does not accept.
Using names that do not match any configured JDK.
3fill in blank
hard

Fix the error in the Jenkins pipeline snippet to use the JDK tool correctly.

Jenkins
pipeline {
  agent any
  tools {
    jdk '[1]'
  }
  stages {
    stage('Test') {
      steps {
        sh 'java -version'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Ajdk-11
BJDK11
Cjdk11
DJava11
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or hyphenated names that do not match the configured tool.
Using generic names like 'Java11' which are not configured.
4fill in blank
hard

Fill both blanks to configure a JDK tool and use it in a Jenkins pipeline.

Jenkins
pipeline {
  agent any
  tools {
    jdk '[1]'
  }
  stages {
    stage('Compile') {
      steps {
        sh '[2] -version'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
AJDK11
Bjava
Cjavac
DJDK8
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'javac' instead of 'java' for version check.
Using wrong JDK tool names.
5fill in blank
hard

Fill all three blanks to define a JDK tool, set it in the pipeline, and run a build command.

Jenkins
pipeline {
  agent any
  tools {
    jdk '[1]'
  }
  stages {
    stage('Build') {
      steps {
        sh '[2] [3]'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
AJDK11
Bjava
C-version
Dmvn
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'mvn' instead of 'java' for JDK verification.
Incorrect JDK tool names.