Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to mark a Jenkins agent as offline.
Jenkins
agent.set[1](true) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'online' instead of 'offline' causes the agent to be marked online.
✗ Incorrect
Setting offline to true marks the agent as offline in Jenkins.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'isOnline()' will check the opposite status.
✗ Incorrect
The method isOffline() returns true if the agent is offline.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'reconnect()' causes a method not found error.
✗ Incorrect
The connect() method is used to reconnect an offline agent.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'SystemCause' for user maintenance is incorrect.
Setting 'online' to true marks the agent online.
✗ Incorrect
Use OfflineCause.UserCause to specify a user-defined offline reason, then set offline to true.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'isOnline' instead of 'Offline' reverses the logic.
Using '=' instead of '==' causes syntax errors.
✗ Incorrect
Use getName() to get the agent's name, check if it is Offline with isOffline(), and compare with == true.