-
Notifications
You must be signed in to change notification settings - Fork 11
/
MacComputerListener.groovy
48 lines (41 loc) · 1.4 KB
/
MacComputerListener.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package fr.edf.jenkins.plugins.mac.slave
import java.util.logging.Level
import java.util.logging.Logger
import hudson.model.Computer
import hudson.model.TaskListener
import hudson.slaves.ComputerListener
import hudson.slaves.OfflineCause
public class MacComputerListener extends ComputerListener {
private static final Logger LOGGER = Logger.getLogger(MacComputerListener.name)
/**
* {@inheritDoc}
*/
@Override
public void onLaunchFailure(Computer c, TaskListener taskListener) throws IOException, InterruptedException {
if(c instanceof MacComputer) {
MacComputer macComputer = (MacComputer) c
LOGGER.log(Level.WARNING, "Mac Agent {0} failed to launch and will be removed", macComputer.getName())
macComputer.getNode().terminate()
}
}
/**
* {@inheritDoc}
*/
@Override
public void onOnline(Computer c, TaskListener listener) {
if(c instanceof MacComputer) {
MacComputer macComputer = (MacComputer) c
LOGGER.log(Level.FINE, "Mac Agent {} is now online", macComputer.name)
}
}
/**
* {@inheritDoc}
*/
@Override
public void onOffline(Computer c, OfflineCause cause) {
if(c instanceof MacComputer) {
MacComputer macComputer = (MacComputer) c
LOGGER.log(Level.FINE, "Mac Agent {} is now offline", macComputer.name)
}
}
}