0
0
Jenkinsdevops~10 mins

Agent availability and offline handling 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 mark a Jenkins agent as offline.

Jenkins
agent.set[1](true)
Drag options to blanks, or click blank then click option'
Aoffline
Bonline
Cavailable
Dbusy
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'online' instead of 'offline' causes the agent to be marked online.
2fill in blank
medium

Complete the code to check if a Jenkins agent is currently offline.

Jenkins
if (agent.is[1]()) {
    println("Agent is offline")
}
Drag options to blanks, or click blank then click option'
Abusy
Bonline
Cavailable
Doffline
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'isOnline()' will check the opposite status.
3fill in blank
hard

Fix the error in the code to reconnect an offline Jenkins agent.

Jenkins
if (agent.isOffline()) {
    agent.[1]()
}
Drag options to blanks, or click blank then click option'
Aconnect
Breconnect
Cdisconnect
Dshutdown
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'reconnect()' causes a method not found error.
4fill in blank
hard

Fill both blanks to set an offline cause and then mark the agent offline.

Jenkins
agent.setOfflineCause(new [1]("Maintenance"))
agent.set[2](true)
Drag options to blanks, or click blank then click option'
AOfflineCause.UserCause
BOfflineCause.SystemCause
Coffline
Donline
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'SystemCause' for user maintenance is incorrect.
Setting 'online' to true marks the agent online.
5fill in blank
hard

Fill all three blanks to create a map of agent names to their offline status if they are offline.

Jenkins
def offlineAgents = agents.collectEntries { agent ->
    [(agent.[1]()): agent.is[2]() [3] true]
}
Drag options to blanks, or click blank then click option'
AgetName
BOffline
C==
DisOnline
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'isOnline' instead of 'Offline' reverses the logic.
Using '=' instead of '==' causes syntax errors.