本文整理了Java中jenkins.model.Jenkins.getNodes()
方法的一些代码示例,展示了Jenkins.getNodes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jenkins.getNodes()
方法的具体详情如下:
包路径:jenkins.model.Jenkins
类名称:Jenkins
方法名:getNodes
[英]Returns all Nodes in the system, excluding Jenkins instance itself which represents the master.
[中]返回系统中的所有节点,不包括代表主节点的Jenkins实例本身。
代码示例来源:origin: jenkinsci/jenkins
@Override
protected Iterable<Node> getNodes() {
return Jenkins.getActiveInstance().getNodes();
}
代码示例来源:origin: jenkinsci/jenkins
protected UnlabeledNodesIterator() {
super(Jenkins.getActiveInstance().getNodes().iterator());
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Gets all the agent names.
*/
public List<String> get_slaveNames() {
return new AbstractList<String>() {
final List<Node> nodes = Jenkins.getInstance().getNodes();
public String get(int index) {
return nodes.get(index).getNodeName();
}
public int size() {
return nodes.size();
}
};
}
代码示例来源:origin: jenkinsci/jenkins
protected AbstractProject(ItemGroup parent, String name) {
super(parent,name);
buildMixIn = createBuildMixIn();
builds = buildMixIn.getRunMap();
final Jenkins j = Jenkins.getInstance();
final List<Node> nodes = j != null ? j.getNodes() : null;
if(nodes!=null && !nodes.isEmpty()) {
// if a new job is configured with Hudson that already has agent nodes
// make it roamable by default
canRoam = true;
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Gets all {@link Node}s that belong to this label.
*/
@Exported
public Set<Node> getNodes() {
Set<Node> nodes = this.nodes;
if(nodes!=null) return nodes;
Set<Node> r = new HashSet<>();
Jenkins h = Jenkins.getInstance();
if(this.matches(h))
r.add(h);
for (Node n : h.getNodes()) {
if(this.matches(n))
r.add(n);
}
return this.nodes = Collections.unmodifiableSet(r);
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Auto-completion for the "copy from" field in the new job page.
*/
public AutoCompletionCandidates doAutoCompleteCopyNewItemFrom(@QueryParameter final String value) {
final AutoCompletionCandidates r = new AutoCompletionCandidates();
for (Node n : Jenkins.getInstance().getNodes()) {
if (n.getNodeName().startsWith(value))
r.add(n.getNodeName());
}
return r;
}
}
代码示例来源:origin: jenkinsci/configuration-as-code-plugin
@Override
public Set<Attribute<Jenkins,?>> describe() {
final Set<Attribute<Jenkins,?>> attributes = super.describe();
// Add remoting security, all legwork will be done by a configurator
attributes.add(new Attribute<Jenkins, AdminWhitelistRule>("remotingSecurity", AdminWhitelistRule.class)
.getter( j -> j.getInjector().getInstance(AdminWhitelistRule.class) )
.setter( noop() ));
// Override "nodes" getter so we don't export Nodes registered by Cloud plugins
Attribute.<Jenkins,List<Node>>get(attributes, "nodes").ifPresent(a ->
a.getter(j -> j.getNodes().stream()
.filter(node -> node.getDescriptor().isInstantiable())
.collect(Collectors.toList())
)
);
return attributes;
}
代码示例来源:origin: jenkinsci/jenkins
public CauseOfBlockage getCauseOfBlockage() {
Jenkins jenkins = Jenkins.getInstance();
if(isBlockedByShutdown(task))
return CauseOfBlockage.fromMessage(Messages._Queue_HudsonIsAboutToShutDown());
List<CauseOfBlockage> causesOfBlockage = transientCausesOfBlockage;
Label label = getAssignedLabel();
List<Node> allNodes = jenkins.getNodes();
if (allNodes.isEmpty())
label = null; // no master/agent. pointless to talk about nodes
if (label != null) {
Set<Node> nodes = label.getNodes();
if (label.isOffline()) {
if (nodes.size() != 1) return new BecauseLabelIsOffline(label);
else return new BecauseNodeIsOffline(nodes.iterator().next());
} else {
if (causesOfBlockage != null && label.getIdleExecutors() > 0) {
return new CompositeCauseOfBlockage(causesOfBlockage);
}
if (nodes.size() != 1) return new BecauseLabelIsBusy(label);
else return new BecauseNodeIsBusy(nodes.iterator().next());
}
} else if (causesOfBlockage != null && new ComputerSet().getIdleExecutors() > 0) {
return new CompositeCauseOfBlockage(causesOfBlockage);
} else {
return CauseOfBlockage.createNeedsMoreExecutor(Messages._Queue_WaitingForNextAvailableExecutor());
}
}
代码示例来源:origin: jenkinsci/jenkins
Map<Node, Integer> hashSource = new HashMap<Node, Integer>(h.getNodes().size());
for (Node n : h.getNodes()) {
hashSource.put(n, n.getNumExecutors() * 100);
代码示例来源:origin: jenkinsci/jenkins
List<Node> allNodes = Jenkins.getInstance().getNodes();
} else {
if(canRoam) {
for (Node n : Jenkins.getInstance().getNodes()) {
Computer c = n.toComputer();
if (c != null && c.isOnline() && c.isAcceptingTasks() && n.getMode() == Mode.NORMAL) {
代码示例来源:origin: jenkinsci/jenkins
if (!j.getItemMap().isEmpty() || !j.getNodes().isEmpty()) {
return InstallState.UPGRADE;
代码示例来源:origin: jenkinsci/jenkins
Jenkins j = Jenkins.getInstance();
nodes.add(j);
nodes.addAll(j.getNodes());
for (TopLevelItem item : j.allItems(TopLevelItem.class)) {
if (item instanceof ModifiableTopLevelItemGroup) { // no such thing as TopLevelItemGroup, and ItemGroup offers no access to its type parameter
代码示例来源:origin: jenkinsci/configuration-as-code-plugin
@Test
@ConfiguredWithCode("BackwardCompatibilityTest.yml")
public void shloud_accept_legacy_symbols_on_descriptors() throws Exception {
final List<Node> nodes = j.jenkins.getNodes();
System.out.println(nodes);
assertNotNull(j.jenkins.getNode("foo"));
assertNotNull(j.jenkins.getNode("bar"));
assertNotNull(j.jenkins.getNode("qix"));
// see # see https://github.com/jenkinsci/jenkins/pull/3475
// assertNotNull(j.jenkins.getNode("zot"));
final List<ObsoleteConfigurationMonitor.Error> errors = ObsoleteConfigurationMonitor.get().getErrors();
assertEquals("'DumbSlave' is obsolete, please use 'dumb'", errors.get(0).message);
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
@Override
protected Iterable<Node> getNodes() {
return Jenkins.getActiveInstance().getNodes();
}
代码示例来源:origin: org.jenkins-ci.plugins/matrix-project
/**
* If there's no distributed build set up, it's pointless to provide this axis.
* @throws IllegalStateException {@link Jenkins} instance is not ready
*/
@Override
public boolean isInstantiable() {
final Jenkins j = Jenkins.getActiveInstance();
return !j.getNodes().isEmpty() || !j.clouds.isEmpty();
}
代码示例来源:origin: org.jenkins-ci.plugins/matrix-project
/**
* If there's no distributed build set up, it's pointless to provide this axis.
*/
@Override
public boolean isInstantiable() {
final Jenkins j = Jenkins.getActiveInstance();
return !j.getNodes().isEmpty() || !j.clouds.isEmpty();
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
protected AbstractProject(ItemGroup parent, String name) {
super(parent,name);
buildMixIn = createBuildMixIn();
builds = buildMixIn.getRunMap();
final Jenkins j = Jenkins.getInstance();
final List<Node> nodes = j != null ? j.getNodes() : null;
if(nodes!=null && !nodes.isEmpty()) {
// if a new job is configured with Hudson that already has agent nodes
// make it roamable by default
canRoam = true;
}
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* Auto-completion for the "copy from" field in the new job page.
*/
public AutoCompletionCandidates doAutoCompleteCopyNewItemFrom(@QueryParameter final String value) {
final AutoCompletionCandidates r = new AutoCompletionCandidates();
for (Node n : Jenkins.getInstance().getNodes()) {
if (n.getNodeName().startsWith(value))
r.add(n.getNodeName());
}
return r;
}
}
代码示例来源:origin: jenkinsci/throttle-concurrent-builds-plugin
private int buildsOfProjectOnAllNodes(Task task) {
final Jenkins jenkins = Jenkins.getActiveInstance();
int totalRunCount = buildsOfProjectOnNode(jenkins, task);
for (Node node : jenkins.getNodes()) {
totalRunCount += buildsOfProjectOnNode(node, task);
}
return totalRunCount;
}
代码示例来源:origin: org.jenkins-ci.lib/xtrigger-lib
private List<Node> candidatePollingNode(XTriggerLog log) {
log.info("Looking for a candidate node to run the poll.");
AbstractProject project = (AbstractProject) job;
Label targetLabel = getTargetLabel(log);
if (targetLabel != null) {
return getNodesLabel(project, targetLabel);
} else {
return Jenkins.getInstance().getNodes();
}
}
内容来源于网络,如有侵权,请联系作者删除!