本文整理汇总了Java中hudson.slaves.NodePropertyDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java NodePropertyDescriptor类的具体用法?Java NodePropertyDescriptor怎么用?Java NodePropertyDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NodePropertyDescriptor类属于hudson.slaves包,在下文中一共展示了NodePropertyDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findNodeProperty
import hudson.slaves.NodePropertyDescriptor; //导入依赖的package包/类
/**
* 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;
}
示例2: localRootPathToNodeMountPoint
import hudson.slaves.NodePropertyDescriptor; //导入依赖的package包/类
@LocalData
@Test
public void localRootPathToNodeMountPoint() throws Exception {
// The node configuration version 1.0.0 contains a localRootPath field.
// This tests that future versions load this field as nodeMountPoint,
// in other words it tests NodeDisk.readResolve()
Computer computer = jr.getInstance().getComputer("node1");
Node node = computer.getNode();
DescribableList<NodeProperty<?>,NodePropertyDescriptor> props = node.getNodeProperties();
ExternalWorkspaceProperty exwsProp = props.get(ExternalWorkspaceProperty.class);
List<NodeDiskPool> diskPools = exwsProp.getNodeDiskPools();
assertThat(diskPools.size(), is(1));
NodeDiskPool diskPool = diskPools.get(0);
assertThat(diskPool.getDiskPoolRefId(), is ("dp1"));
List<NodeDisk> disks = diskPool.getNodeDisks();
assertThat(disks.size(), is(1));
NodeDisk disk = disks.get(0);
assertThat(disk.getDiskRefId(), is("d1"));
assertThat(disk.getNodeMountPoint(), is("/tmp/dp1/d1"));
}
示例3: configDefaults
import hudson.slaves.NodePropertyDescriptor; //导入依赖的package包/类
/**
* Xstream ignores default field values, so set them explicitly
*/
private void configDefaults() {
if (mode == null) {
mode = Node.Mode.NORMAL;
}
if (retentionStrategy == null) {
retentionStrategy = new DockerOnceRetentionStrategy(10);
}
if (pullStrategy == null) {
pullStrategy = DockerImagePullStrategy.PULL_LATEST;
}
if (nodeProperties == null) {
nodeProperties =
new DescribableList<NodeProperty<?>, NodePropertyDescriptor>(Jenkins.getInstance());
}
}
示例4: getNodePropertiesDescriptors
import hudson.slaves.NodePropertyDescriptor; //导入依赖的package包/类
/**
* Get a list of all {@link NodePropertyDescriptor}s we can use to define DockerSlave NodeProperties.
*/
public List<NodePropertyDescriptor> getNodePropertiesDescriptors() {
// Copy/paste hudson.model.Slave.SlaveDescriptor.nodePropertyDescriptors marked as @Restricted for reasons I don't get
List<NodePropertyDescriptor> result = new ArrayList<NodePropertyDescriptor>();
Collection<NodePropertyDescriptor> list =
(Collection) Jenkins.getInstance().getDescriptorList(NodeProperty.class);
for (NodePropertyDescriptor npd : DescriptorVisibilityFilter.applyType(DockerTransientNode.class, list)) {
if (npd.isApplicable(DockerTransientNode.class)) {
result.add(npd);
}
}
final Iterator<NodePropertyDescriptor> iterator = result.iterator();
while (iterator.hasNext()) {
final NodePropertyDescriptor de = iterator.next();
// see https://issues.jenkins-ci.org/browse/JENKINS-47697
if ("org.jenkinsci.plugins.matrixauth.AuthorizationMatrixNodeProperty".equals(de.getKlass().toJavaClass().getName())) {
iterator.remove();
}
}
return result;
}
示例5: getNodePropertyDescriptors
import hudson.slaves.NodePropertyDescriptor; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public static List<NodePropertyDescriptor> getNodePropertyDescriptors(Class<? extends Node> clazz) {
List<NodePropertyDescriptor> result = new ArrayList<>();
Collection<NodePropertyDescriptor> list = (Collection) Jenkins.getInstance().getDescriptorList(NodeProperty.class);
for (NodePropertyDescriptor npd : list) {
if (npd.isApplicable(clazz)) {
result.add(npd);
}
}
return result;
}
示例6: start
import hudson.slaves.NodePropertyDescriptor; //导入依赖的package包/类
@Override
public boolean start() throws Exception {
LOGGER.log(Level.FINE, "Starting container step.");
String containerName = step.getName();
KubernetesNodeContext nodeContext = new KubernetesNodeContext(getContext());
client = nodeContext.connectToCloud();
EnvironmentExpander env = getContext().get(EnvironmentExpander.class);
EnvVars globalVars = null;
Jenkins instance = Jenkins.getInstance();
DescribableList<NodeProperty<?>, NodePropertyDescriptor> globalNodeProperties = instance
.getGlobalNodeProperties();
List<EnvironmentVariablesNodeProperty> envVarsNodePropertyList = globalNodeProperties
.getAll(EnvironmentVariablesNodeProperty.class);
if (envVarsNodePropertyList != null && envVarsNodePropertyList.size() != 0) {
globalVars = envVarsNodePropertyList.get(0).getEnvVars();
}
decorator = new ContainerExecDecorator();
decorator.setClient(client);
decorator.setPodName(nodeContext.getPodName());
decorator.setContainerName(containerName);
decorator.setNamespace(nodeContext.getNamespace());
decorator.setEnvironmentExpander(env);
decorator.setWs(getContext().get(FilePath.class));
decorator.setGlobalVars(globalVars);
getContext().newBodyInvoker()
.withContext(BodyInvoker
.mergeLauncherDecorators(getContext().get(LauncherDecorator.class), decorator))
.withCallback(new ContainerExecCallback(decorator))
.start();
return false;
}
示例7: configureCloud
import hudson.slaves.NodePropertyDescriptor; //导入依赖的package包/类
@Before
public void configureCloud() throws Exception {
cloud = setupCloud(this);
createSecret(cloud.connect());
cloud.getTemplates().clear();
cloud.addTemplate(buildBusyboxTemplate("busybox"));
// Agents running in Kubernetes (minikube) need to connect to this server, so localhost does not work
URL url = r.getURL();
String hostAddress = System.getProperty("jenkins.host.address");
if (hostAddress == null) {
hostAddress = InetAddress.getLocalHost().getHostAddress();
}
URL nonLocalhostUrl = new URL(url.getProtocol(), hostAddress, url.getPort(),
url.getFile());
JenkinsLocationConfiguration.get().setUrl(nonLocalhostUrl.toString());
r.jenkins.clouds.add(cloud);
DescribableList<NodeProperty<?>, NodePropertyDescriptor> list = r.jenkins.getGlobalNodeProperties();
EnvironmentVariablesNodeProperty newEnvVarsNodeProperty = new hudson.slaves.EnvironmentVariablesNodeProperty();
list.add(newEnvVarsNodeProperty);
EnvVars envVars = newEnvVarsNodeProperty.getEnvVars();
envVars.put("GLOBAL", "GLOBAL");
envVars.put("JAVA_HOME_X", "java-home-x");
r.jenkins.save();
}
示例8: Expand
import hudson.slaves.NodePropertyDescriptor; //导入依赖的package包/类
public Expand(Map<String, String> map) {
Jenkins jenkins = Jenkins.getInstance();
if (jenkins == null) {
logger.warning("Jenkins instance is null!");
return;
}
DescribableList<NodeProperty<?>, NodePropertyDescriptor> props = jenkins.getGlobalNodeProperties();
if (props != null) {
for (NodeProperty<?> node : props) {
if (node instanceof EnvironmentVariablesNodeProperty) {
EnvironmentVariablesNodeProperty env = (EnvironmentVariablesNodeProperty) node;
formatTags.putAll((env).getEnvVars());
}
}
}
for (Entry<String, String> entry : map.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (ReviewProp.isProp(key)) {
// Known Perforce Review property; prefix with namespace
key = ReviewProp.NAMESPACE + key;
}
set(key, value);
}
}
示例9: getGlobalNodeProperties
import hudson.slaves.NodePropertyDescriptor; //导入依赖的package包/类
/**
* Get a map with the global node properties.
*
* @since 1.6
* @return map with global node properties
*/
public static @Nonnull Map<String, Object> getGlobalNodeProperties() {
Map<String, Object> map = new HashMap<String, Object>();
Jenkins instance = Jenkins.getInstance();
DescribableList<NodeProperty<?>, NodePropertyDescriptor> globalNodeProperties = instance.getGlobalNodeProperties();
if (globalNodeProperties != null) {
for (NodeProperty<?> nodeProperty : globalNodeProperties) {
if (nodeProperty instanceof EnvironmentVariablesNodeProperty) {
EnvironmentVariablesNodeProperty envNodeProperty = (EnvironmentVariablesNodeProperty) nodeProperty;
map.putAll(envNodeProperty.getEnvVars());
}
}
}
return map;
}
示例10: getNodePropertyDescriptors
import hudson.slaves.NodePropertyDescriptor; //导入依赖的package包/类
@Override
public List<NodePropertyDescriptor> getNodePropertyDescriptors() {
initPython();
if (pexec.isImplemented(11)) {
return (List) pexec.execPython("get_node_property_descriptors");
} else {
return super.getNodePropertyDescriptors();
}
}
示例11: readResolve
import hudson.slaves.NodePropertyDescriptor; //导入依赖的package包/类
public Object readResolve() {
if (nodeProperties == null) {
nodeProperties = new DescribableList<NodeProperty<?>,NodePropertyDescriptor>(Jenkins.getInstance());
}
if (minExecutors == 0) {
this.minExecutors = 1;
}
return this;
}
示例12: getNodeProperties
import hudson.slaves.NodePropertyDescriptor; //导入依赖的package包/类
public DescribableList<NodeProperty<?>, NodePropertyDescriptor> getNodeProperties() {
return nodeProperties;
}
示例13: readResolve
import hudson.slaves.NodePropertyDescriptor; //导入依赖的package包/类
public Object readResolve() {
if(nodeProperties==null)
nodeProperties = new DescribableList<NodeProperty<?>,NodePropertyDescriptor>(Jenkins.getInstance());
return this;
}
示例14: getNodeProperties
import hudson.slaves.NodePropertyDescriptor; //导入依赖的package包/类
@Override
public DescribableList<NodeProperty<?>, NodePropertyDescriptor> getNodeProperties() {
initPython();
return (DescribableList) pexec.execPython("get_node_properties");
}
示例15: superGetNodePropertyDescriptors
import hudson.slaves.NodePropertyDescriptor; //导入依赖的package包/类
public List<NodePropertyDescriptor> superGetNodePropertyDescriptors() {
return super.getNodePropertyDescriptors();
}