Complete the code to set the Jenkins executor count to improve parallel builds.
jenkins.model.Jenkins.instance.setNumExecutors([1])Setting the number of executors to 10 allows Jenkins to run 10 builds in parallel, improving performance.
Complete the code to enable the Jenkins build queue to timeout after a certain period.
jenkins.model.Jenkins.instance.getQueue().setBuildableTimeout([1])600000 milliseconds (10 minutes) sets a reasonable timeout for build queue items to wait before timing out.
Fix the error in the code to properly set the Jenkins system message for performance monitoring.
jenkins.model.Jenkins.instance.setSystemMessage([1])The system message must be a string, so it needs to be enclosed in double quotes.
Fill both blanks to create a map of job names to their last build duration in milliseconds.
def durations = jenkins.model.Jenkins.instance.getAllItems().collectEntries { job -> [job.[1], job.getLastBuild()?.[2] ?: 0] }
Use 'name' to get the job name and 'getDuration' method to get the last build duration.
Fill all three blanks to filter jobs with last build duration greater than 5 minutes and create a map of job names to durations.
def slowJobs = jenkins.model.Jenkins.instance.getAllItems().findAll { job -> job.getLastBuild()?.[1] ?: 0 [2] [3] } .collectEntries { job -> [job.name, job.getLastBuild().getDuration()] }
Use 'getDuration()' to get build duration, '>' to compare, and 300000 milliseconds (5 minutes) as the threshold.