本文整理匯總了Java中jenkins.model.Jenkins.getComputers方法的典型用法代碼示例。如果您正苦於以下問題:Java Jenkins.getComputers方法的具體用法?Java Jenkins.getComputers怎麽用?Java Jenkins.getComputers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類jenkins.model.Jenkins
的用法示例。
在下文中一共展示了Jenkins.getComputers方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getComputer
import jenkins.model.Jenkins; //導入方法依賴的package包/類
/**
* Gets the computer for the current launcher.
*
* @return the computer
* @throws AbortException in case of error.
*/
@Nonnull
private Computer getComputer() throws AbortException {
if (computer != null) {
return computer;
}
String node = null;
Jenkins j = Jenkins.getActiveInstance();
for (Computer c : j.getComputers()) {
if (c.getChannel() == launcher.getChannel()) {
node = c.getName();
break;
}
}
if (node == null) {
throw new AbortException("Could not find computer for the job");
}
computer = j.getComputer(node);
if (computer == null) {
throw new AbortException("No such computer " + node);
}
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "Computer: {0}", computer.getName());
try {
LOGGER.log(Level.FINE, "Env: {0}", computer.getEnvironment());
} catch (IOException | InterruptedException e) {// ignored
}
}
return computer;
}