0
0
Jenkinsdevops~10 mins

Monitoring Jenkins health - Interactive Code Practice

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

Complete the code to check Jenkins service status using systemctl.

Jenkins
systemctl [1] jenkins
Drag options to blanks, or click blank then click option'
Astatus
Bstart
Cstop
Drestart
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'start' instead of 'status' will try to start Jenkins instead of checking it.
Using 'stop' will stop Jenkins, which is not what we want here.
2fill in blank
medium

Complete the Jenkins CLI command to get the current system health report.

Jenkins
java -jar jenkins-cli.jar -s http://localhost:8080 [1]
Drag options to blanks, or click blank then click option'
Awho-am-i
Bbuild
Chealth-report
Drestart
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'build' runs a job, not health check.
Using 'restart' restarts Jenkins, not reports health.
3fill in blank
hard

Fix the error in the curl command to get Jenkins health API JSON output.

Jenkins
curl -s http://localhost:8080/[1]/api/json
Drag options to blanks, or click blank then click option'
Ahealth
Bcomputer
Cqueue
Djob
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'job' returns job info, not health.
Using 'computer' returns node info, not health.
4fill in blank
hard

Fill both blanks to create a Jenkins pipeline step that checks health and fails if unhealthy.

Jenkins
stage('Check Health') {
  steps {
    script {
      def health = sh(script: 'curl -s http://localhost:8080/[1]/api/json', returnStdout: true).trim()
      if (!health.contains('[2]')) {
        error('Jenkins health check failed!')
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Ahealth
Bhealthy
Cunhealthy
Dcomputer
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'computer' instead of 'health' for the endpoint.
Checking for 'unhealthy' instead of 'healthy' causes wrong logic.
5fill in blank
hard

Fill all three blanks to create a Jenkins Groovy script that prints the health report summary.

Jenkins
import jenkins.model.*

def instance = Jenkins.getInstance()
def healthReport = instance.get[1]().get[2]()
println("Health Summary: " + healthReport.[3])
Drag options to blanks, or click blank then click option'
AInstance
BOverallHealth
Cdescription
DComputer
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Computer' instead of 'Instance' for the Jenkins object.
Trying to print the whole object instead of its description.