0
0
Jenkinsdevops~10 mins

Performance tuning 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 Jenkins executor count to improve parallel builds.

Jenkins
jenkins.model.Jenkins.instance.setNumExecutors([1])
Drag options to blanks, or click blank then click option'
A0
B5
C-1
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Setting executors to 0 disables builds.
Negative numbers cause errors.
2fill in blank
medium

Complete the code to enable the Jenkins build queue to timeout after a certain period.

Jenkins
jenkins.model.Jenkins.instance.getQueue().setBuildableTimeout([1])
Drag options to blanks, or click blank then click option'
A600000
B30000
C0
D-100
Attempts:
3 left
💡 Hint
Common Mistakes
Using zero disables timeout.
Negative values cause errors.
3fill in blank
hard

Fix the error in the code to properly set the Jenkins system message for performance monitoring.

Jenkins
jenkins.model.Jenkins.instance.setSystemMessage([1])
Drag options to blanks, or click blank then click option'
APerformance tuning enabled
B"Performance tuning enabled"
CPerformance tuning enabled;
D'Performance tuning enabled'
Attempts:
3 left
💡 Hint
Common Mistakes
Missing quotes cause syntax errors.
Adding semicolons is unnecessary here.
4fill in blank
hard

Fill both blanks to create a map of job names to their last build duration in milliseconds.

Jenkins
def durations = jenkins.model.Jenkins.instance.getAllItems().collectEntries { job -> [job.[1], job.getLastBuild()?.[2] ?: 0] }
Drag options to blanks, or click blank then click option'
Aname
Bduration
Ctimestamp
DgetDuration
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'duration' property directly causes errors.
Using 'timestamp' gives build start time, not duration.
5fill in blank
hard

Fill all three blanks to filter jobs with last build duration greater than 5 minutes and create a map of job names to durations.

Jenkins
def slowJobs = jenkins.model.Jenkins.instance.getAllItems().findAll { job -> job.getLastBuild()?.[1] ?: 0 [2] [3] } .collectEntries { job -> [job.name, job.getLastBuild().getDuration()] }
Drag options to blanks, or click blank then click option'
AgetDuration()
B>
C300000
Dduration
Attempts:
3 left
💡 Hint
Common Mistakes
Using property 'duration' instead of method causes errors.
Using '<' instead of '>' reverses the filter.