本文整理了Java中hudson.model.Node.getNodeProperties()
方法的一些代码示例,展示了Node.getNodeProperties()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getNodeProperties()
方法的具体详情如下:
包路径:hudson.model.Node
类名称:Node
方法名:getNodeProperties
[英]Gets the NodeProperty instances configured for this Node.
[中]获取为此节点配置的NodeProperty实例。
代码示例来源:origin: jenkinsci/jenkins
/**
* Gets the specified property or null if the property is not configured for this Node.
*
* @param clazz the type of the property
*
* @return null if the property is not configured
*
* @since 2.37
*/
@CheckForNull
public <T extends NodeProperty> T getNodeProperty(Class<T> clazz)
{
for (NodeProperty p: getNodeProperties()) {
if (clazz.isInstance(p)) {
return clazz.cast(p);
}
}
return null;
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Gets the property from the given classname or null if the property
* is not configured for this Node.
*
* @param className The classname of the property
*
* @return null if the property is not configured
*
* @since 2.37
*/
@CheckForNull
public NodeProperty getNodeProperty(String className)
{
for (NodeProperty p: getNodeProperties()) {
if (p.getClass().getName().equals(className)) {
return p;
}
}
return null;
}
代码示例来源:origin: jenkinsci/jenkins
@Override
public Object onConvert(Type targetType, Class targetTypeErasure, Object jsonSource) {
if (jsonForProperties != jsonSource) {
return old.get().onConvert(targetType, targetTypeErasure, jsonSource);
}
try {
DescribableList<NodeProperty<?>, NodePropertyDescriptor> tmp = new DescribableList<NodeProperty<?>, NodePropertyDescriptor>(Saveable.NOOP,getNodeProperties().toList());
tmp.rebuild(req, jsonForProperties, NodeProperty.all());
return tmp.toList();
} catch (FormException e) {
throw new IllegalArgumentException(e);
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
}
}));
代码示例来源:origin: jenkinsci/jenkins
ToolLocationNodeProperty property = node.getNodeProperties().get(ToolLocationNodeProperty.class);
if (property != null) {
result = property.getHome(installation);
代码示例来源:origin: jenkinsci/jenkins
/**
* Creates an environment variable override to be used for launching processes on this node.
*
* @see ProcStarter#envs(Map)
* @since 1.489
*/
public @Nonnull EnvVars buildEnvironment(@Nonnull TaskListener listener) throws IOException, InterruptedException {
EnvVars env = new EnvVars();
Node node = getNode();
if (node==null) return env; // bail out
for (NodeProperty nodeProperty: Jenkins.getInstance().getGlobalNodeProperties()) {
nodeProperty.buildEnvVars(env,listener);
}
for (NodeProperty nodeProperty: node.getNodeProperties()) {
nodeProperty.buildEnvVars(env,listener);
}
// TODO: hmm, they don't really belong
String rootUrl = Jenkins.getInstance().getRootUrl();
if(rootUrl!=null) {
env.put("HUDSON_URL", rootUrl); // Legacy.
env.put("JENKINS_URL", rootUrl);
}
return env;
}
代码示例来源:origin: jenkinsci/jenkins
for (NodeProperty prop: getNodeProperties()) {
CauseOfBlockage c = prop.canTake(item);
if (c!=null) return c;
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* Gets the specified property or null if the property is not configured for this Node.
*
* @param clazz the type of the property
*
* @return null if the property is not configured
*
* @since 2.37
*/
@CheckForNull
public <T extends NodeProperty> T getNodeProperty(Class<T> clazz)
{
for (NodeProperty p: getNodeProperties()) {
if (clazz.isInstance(p)) {
return clazz.cast(p);
}
}
return null;
}
代码示例来源:origin: org.jenkins-ci.plugins/ssh-slaves
private EnvVars getEnvVars(Node n) {
return getEnvVars(n.getNodeProperties());
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* Gets the property from the given classname or null if the property
* is not configured for this Node.
*
* @param className The classname of the property
*
* @return null if the property is not configured
*
* @since 2.37
*/
@CheckForNull
public NodeProperty getNodeProperty(String className)
{
for (NodeProperty p: getNodeProperties()) {
if (p.getClass().getName().equals(className)) {
return p;
}
}
return null;
}
代码示例来源:origin: jenkinsci/ssh-slaves-plugin
private EnvVars getEnvVars(Node n) {
return getEnvVars(n.getNodeProperties());
}
代码示例来源:origin: jenkinsci/ssh-slaves-plugin
private List<String> lookForJavaHome(Node node) {
List<String> ret = new ArrayList<>();
if(node != null && node.getNodeProperties() != null){
for (NodeProperty property : node.getNodeProperties()){
if(property instanceof EnvironmentVariablesNodeProperty){
EnvVars env = ((EnvironmentVariablesNodeProperty) property).getEnvVars();
if (env != null && env.containsKey(JAVA_HOME)) {
ret.add(env.get(JAVA_HOME) + BIN_JAVA);
}
}
}
}
return ret;
}
代码示例来源:origin: jenkinsci/external-workspace-manager-plugin
/**
* Finds the {@link NodeProperty} for the external workspace definition.
*
* @param node the current node
* @return the node property for the external workspace manager
* @throws IOException if node property was not found
*/
@Nonnull
private static ExternalWorkspaceProperty findNodeProperty(Node node) throws IOException {
DescribableList<NodeProperty<?>, NodePropertyDescriptor> nodeProperties = node.getNodeProperties();
ExternalWorkspaceProperty exwsNodeProperty = null;
for (NodeProperty<?> nodeProperty : nodeProperties) {
if (nodeProperty instanceof ExternalWorkspaceProperty) {
exwsNodeProperty = (ExternalWorkspaceProperty) nodeProperty;
break;
}
}
if (exwsNodeProperty == null) {
String message = format("There is no External Workspace config defined in Node '%s' config", node.getDisplayName());
throw new AbortException(message);
}
return exwsNodeProperty;
}
代码示例来源:origin: jenkinsci/ssh-slaves-plugin
private List<String> lookForTools(Node node) {
List<String> ret = new ArrayList<>();
Descriptor jdk = Jenkins.getInstance().getDescriptorByType(JDK.DescriptorImpl.class);
if(node != null && node.getNodeProperties() != null){
for (NodeProperty property : node.getNodeProperties()){
if (property instanceof ToolLocationNodeProperty) {
for (ToolLocation tool : ((ToolLocationNodeProperty) property).getLocations()) {
if (tool.getType() == jdk) {
ret.add(tool.getHome() + BIN_JAVA);
}
}
}
}
}
return ret;
}
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
@Override
public Object onConvert(Type targetType, Class targetTypeErasure, Object jsonSource) {
if (jsonForProperties != jsonSource) {
return old.get().onConvert(targetType, targetTypeErasure, jsonSource);
}
try {
DescribableList<NodeProperty<?>, NodePropertyDescriptor> tmp = new DescribableList<NodeProperty<?>, NodePropertyDescriptor>(Saveable.NOOP,getNodeProperties().toList());
tmp.rebuild(req, jsonForProperties, NodeProperty.all());
return tmp.toList();
} catch (FormException e) {
throw new IllegalArgumentException(e);
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
}
}));
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
/**
* Checks if the location of the tool is overridden for the given node, and if so,
* return the node-specific home directory. Otherwise return {@code installation.getHome()}
*
* <p>
* This is the core logic behind {@link NodeSpecific#forNode(Node)} for {@link ToolInstallation}.
*
* @return
* never null.
* @deprecated since 2009-04-09.
* Use {@link ToolInstallation#translateFor(Node,TaskListener)}
*/
public static String getToolHome(Node node, ToolInstallation installation, TaskListener log) throws IOException, InterruptedException {
String result = null;
// node-specific configuration takes precedence
ToolLocationNodeProperty property = node.getNodeProperties().get(ToolLocationNodeProperty.class);
if (property != null) result = property.getHome(installation);
if (result != null) return result;
// consult translators
for( ToolLocationTranslator t : ToolLocationTranslator.all() ) {
result = t.getToolHome(node, installation, log);
if(result!=null) return result;
}
// fall back is no-op
return installation.getHome();
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
/**
* Checks if the location of the tool is overridden for the given node, and if so,
* return the node-specific home directory. Otherwise return {@code installation.getHome()}
*
* <p>
* This is the core logic behind {@link NodeSpecific#forNode(Node)} for {@link ToolInstallation}.
*
* @return
* never null.
* @deprecated since 2009-04-09.
* Use {@link ToolInstallation#translateFor(Node,TaskListener)}
*/
public static String getToolHome(Node node, ToolInstallation installation, TaskListener log) throws IOException, InterruptedException {
String result = null;
// node-specific configuration takes precedence
ToolLocationNodeProperty property = node.getNodeProperties().get(ToolLocationNodeProperty.class);
if (property != null) result = property.getHome(installation);
if (result != null) return result;
// consult translators
for( ToolLocationTranslator t : ToolLocationTranslator.all() ) {
result = t.getToolHome(node, installation, log);
if(result!=null) return result;
}
// fall back is no-op
return installation.getHome();
}
代码示例来源:origin: hudson/hudson-2.x
/**
* Checks if the location of the tool is overridden for the given node, and if so,
* return the node-specific home directory. Otherwise return {@code installation.getHome()}
*
* <p>
* This is the core logic behind {@link NodeSpecific#forNode(Node)} for {@link ToolInstallation}.
*
* @return
* never null.
* @deprecated since 2009-04-09.
* Use {@link ToolInstallation#translateFor(Node,TaskListener)}
*/
public static String getToolHome(Node node, ToolInstallation installation, TaskListener log) throws IOException, InterruptedException {
String result = null;
// node-specific configuration takes precedence
ToolLocationNodeProperty property = node.getNodeProperties().get(ToolLocationNodeProperty.class);
if (property != null) result = property.getHome(installation);
if (result != null) return result;
// consult translators
for( ToolLocationTranslator t : ToolLocationTranslator.all() ) {
result = t.getToolHome(node, installation, log);
if(result!=null) return result;
}
// fall back is no-op
return installation.getHome();
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* Creates an environment variable override to be used for launching processes on this node.
*
* @see ProcStarter#envs(Map)
* @since 1.489
*/
public @Nonnull EnvVars buildEnvironment(@Nonnull TaskListener listener) throws IOException, InterruptedException {
EnvVars env = new EnvVars();
Node node = getNode();
if (node==null) return env; // bail out
for (NodeProperty nodeProperty: Jenkins.getInstance().getGlobalNodeProperties()) {
nodeProperty.buildEnvVars(env,listener);
}
for (NodeProperty nodeProperty: node.getNodeProperties()) {
nodeProperty.buildEnvVars(env,listener);
}
// TODO: hmm, they don't really belong
String rootUrl = Jenkins.getInstance().getRootUrl();
if(rootUrl!=null) {
env.put("HUDSON_URL", rootUrl); // Legacy.
env.put("JENKINS_URL", rootUrl);
}
return env;
}
代码示例来源:origin: org.jvnet.hudson.plugins/m2-extra-steps
public void buildEnvVars(AbstractBuild<?, ?> build, EnvVars env) {
for (NodeProperty nodeProperty: Hudson.getInstance().getGlobalNodeProperties()) {
if (nodeProperty instanceof EnvironmentVariablesNodeProperty) {
env.overrideAll(((EnvironmentVariablesNodeProperty)nodeProperty).getEnvVars());
}
}
for (NodeProperty nodeProperty: Computer.currentComputer().getNode().getNodeProperties()) {
if (nodeProperty instanceof EnvironmentVariablesNodeProperty) {
env.overrideAll(((EnvironmentVariablesNodeProperty)nodeProperty).getEnvVars());
}
}
}
}
代码示例来源:origin: org.eclipse.hudson/hudson-core
public CauseOfBlockage canTake(Queue.BuildableItem item) {
Label l = item.getAssignedLabel();
if(l!=null && !l.contains(this))
return CauseOfBlockage.fromMessage(Messages._Node_LabelMissing(getNodeName(),l)); // the task needs to be executed on label that this node doesn't have.
if(l==null && getMode()== Mode.EXCLUSIVE)
return CauseOfBlockage.fromMessage(Messages._Node_BecauseNodeIsReserved(getNodeName())); // this node is reserved for tasks that are tied to it
// Check each NodeProperty to see whether they object to this node
// taking the task
for (NodeProperty prop: getNodeProperties()) {
CauseOfBlockage c = prop.canTake(item);
if (c!=null) return c;
}
// Looks like we can take the task
return null;
}
内容来源于网络,如有侵权,请联系作者删除!