Complete the code to check Jenkins service status using systemctl.
systemctl [1] jenkinsThe status command shows the current state of the Jenkins service.
Complete the Jenkins CLI command to get the current system health report.
java -jar jenkins-cli.jar -s http://localhost:8080 [1]
The health-report command fetches Jenkins system health information.
Fix the error in the curl command to get Jenkins health API JSON output.
curl -s http://localhost:8080/[1]/api/json
The health endpoint provides Jenkins health status in JSON format.
Fill both blanks to create a Jenkins pipeline step that checks health and fails if unhealthy.
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!') } } } }
The script fetches health JSON from the health endpoint and checks if it contains the word healthy. If not, it fails the build.
Fill all three blanks to create a Jenkins Groovy script that prints the health report summary.
import jenkins.model.* def instance = Jenkins.getInstance() def healthReport = instance.get[1]().get[2]() println("Health Summary: " + healthReport.[3])
The script gets the Jenkins instance, then calls getOverallHealth() to get the health report, and prints its description summary.