• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java EnvironmentVariablesNodeProperty类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中hudson.slaves.EnvironmentVariablesNodeProperty的典型用法代码示例。如果您正苦于以下问题:Java EnvironmentVariablesNodeProperty类的具体用法?Java EnvironmentVariablesNodeProperty怎么用?Java EnvironmentVariablesNodeProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



EnvironmentVariablesNodeProperty类属于hudson.slaves包,在下文中一共展示了EnvironmentVariablesNodeProperty类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getEnvironment

import hudson.slaves.EnvironmentVariablesNodeProperty; //导入依赖的package包/类
/**
 * Returns the environment variables for the given {@link Node}.
 * 
 * @param node
 *            The {@link Node} to get the environment variables from
 * @param additionalEnvironment
 *            environment added to the environment from the {@link Node}.
 *            Take precedence over environment from the {@link Node}.
 * @return the environment variables for the given {@link Node}
 * @since 1.0
 */
public static EnvVars getEnvironment(Node node,
		EnvVars additionalEnvironment) {
	EnvVars envVars = new EnvVars();
	EnvironmentVariablesNodeProperty env = node.getNodeProperties().get(
			EnvironmentVariablesNodeProperty.class);
	if (env != null) {
		envVars.putAll(env.getEnvVars());
	}
	envVars.overrideAll(additionalEnvironment);
	return envVars;
}
 
开发者ID:bombardier-transportation,项目名称:distributed-test-job,代码行数:23,代码来源:NodeUtils.java


示例2: start

import hudson.slaves.EnvironmentVariablesNodeProperty; //导入依赖的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;
}
 
开发者ID:carlossg,项目名称:jenkins-kubernetes-plugin,代码行数:34,代码来源:ContainerStepExecution.java


示例3: configureCloud

import hudson.slaves.EnvironmentVariablesNodeProperty; //导入依赖的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();
}
 
开发者ID:carlossg,项目名称:jenkins-kubernetes-plugin,代码行数:29,代码来源:AbstractKubernetesPipelineTest.java


示例4: Expand

import hudson.slaves.EnvironmentVariablesNodeProperty; //导入依赖的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);
	}
}
 
开发者ID:p4paul,项目名称:p4-jenkins,代码行数:28,代码来源:Expand.java


示例5: getGlobalNodeProperties

import hudson.slaves.EnvironmentVariablesNodeProperty; //导入依赖的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;
}
 
开发者ID:imoutsatsos,项目名称:uno-choice-plugin,代码行数:21,代码来源:Utils.java


示例6: testGetGlobalNodeProperties

import hudson.slaves.EnvironmentVariablesNodeProperty; //导入依赖的package包/类
@Test
public void testGetGlobalNodeProperties() {
    Map<?, ?> map = Utils.getGlobalNodeProperties();
    Map<String, String> testMap = new HashMap<String, String>();
    testMap.put("time", "20:13:13");
    EnvironmentVariablesNodeProperty.Entry entry = new EnvironmentVariablesNodeProperty.Entry("time",
            testMap.get("time"));
    EnvironmentVariablesNodeProperty envVarsNodeProp = new EnvironmentVariablesNodeProperty(entry);
    j.jenkins.getGlobalNodeProperties().add(envVarsNodeProp);
    map = Utils.getGlobalNodeProperties();
    assertEquals("20:13:13", map.values().iterator().next());
}
 
开发者ID:imoutsatsos,项目名称:uno-choice-plugin,代码行数:13,代码来源:TestUtils.java


示例7: testScriptAccessingGlobalProperties

import hudson.slaves.EnvironmentVariablesNodeProperty; //导入依赖的package包/类
@Test
public void testScriptAccessingGlobalProperties() {
    Map<String, String> testMap = new HashMap<String, String>();
    testMap.put("time", "20:13:13");
    EnvironmentVariablesNodeProperty.Entry entry = new EnvironmentVariablesNodeProperty.Entry("NODE_TIME",
            testMap.get("time"));
    EnvironmentVariablesNodeProperty envVarsNodeProp = new EnvironmentVariablesNodeProperty(entry);
    j.jenkins.getGlobalNodeProperties().add(envVarsNodeProp);
    GroovyScript script = new GroovyScript(new SecureGroovyScript(SCRIPT, Boolean.FALSE, null),
            new SecureGroovyScript(FALLBACK_SCRIPT, Boolean.FALSE, null));
    ChoiceParameter param = new ChoiceParameter("param000", "description", "randomName", script,
            CascadeChoiceParameter.ELEMENT_TYPE_FORMATTED_HIDDEN_HTML, true, 0);

    assertEquals(Arrays.asList("a", "b", "20:13:13").toString(), param.getChoices().values().toString());
}
 
开发者ID:imoutsatsos,项目名称:uno-choice-plugin,代码行数:16,代码来源:TestGlobalNodePropertiesScript.java


示例8: getEnvironmentVariables

import hudson.slaves.EnvironmentVariablesNodeProperty; //导入依赖的package包/类
private Properties getEnvironmentVariables() {
    Properties properties;
    EnvironmentVariablesNodeProperty environmentVariablesNodeProperty;

    properties = new Properties();
    environmentVariablesNodeProperty = Jenkins.getInstance().getGlobalNodeProperties().get(EnvironmentVariablesNodeProperty.class);

    if (environmentVariablesNodeProperty != null) {
        for (Map.Entry<String, String> entry : environmentVariablesNodeProperty.getEnvVars().entrySet()) {
            properties.setProperty(entry.getKey(), entry.getValue());
        }
    }

    return properties;
}
 
开发者ID:maxbraun,项目名称:job-profiles,代码行数:16,代码来源:MavenProjectResolver.java


示例9: setEnvironmentVariables

import hudson.slaves.EnvironmentVariablesNodeProperty; //导入依赖的package包/类
public static void setEnvironmentVariables(JenkinsRule j, Map<String, String> params) throws IOException {
    EnvironmentVariablesNodeProperty prop = new EnvironmentVariablesNodeProperty();
    EnvVars envVars = prop.getEnvVars();
    envVars.putAll(params);
    j.jenkins.getGlobalNodeProperties().add(prop);
}
 
开发者ID:uber,项目名称:phabricator-jenkins-plugin,代码行数:7,代码来源:TestUtils.java


示例10: call

import hudson.slaves.EnvironmentVariablesNodeProperty; //导入依赖的package包/类
@Override
public Boolean call() throws Throwable {
    final Jenkins jenkins = Jenkins.getInstance();

    String logName = "com.github.kostyasha.yad";
    final LogRecorder logRecorder = new LogRecorder(logName);
    logRecorder.targets.add(new LogRecorder.Target("com.github.kostyasha.yad", Level.ALL));
    jenkins.getLog().logRecorders.put("logName", logRecorder);
    logRecorder.save();

    // prepare jenkins global (url, cred)
    JenkinsLocationConfiguration.get().setUrl(String.format("http://%s:%d", dockerUri.getHost(), jenkinsPort));

    SystemCredentialsProvider.getInstance().getCredentials().add(dockerServerCredentials);

    //verify doTestConnection
    final DescriptorImpl descriptor = (DescriptorImpl) jenkins.getDescriptor(DockerConnector.class);
    checkFormValidation(descriptor.doTestConnection(dockerUri.toString(), "",
            dockerServerCredentials.getId(), ConnectorType.NETTY, 10 * 1000, 11 * 1000));
    checkFormValidation(descriptor.doTestConnection(dockerUri.toString(), "",
            dockerServerCredentials.getId(), JERSEY, 10 * 1000, 11 * 1000));

    // prepare Docker Cloud
    final DockerConnector dockerConnector = new DockerConnector(dockerUri.toString());
    dockerConnector.setCredentialsId(dockerServerCredentials.getId());
    dockerConnector.setConnectTimeout(10 * 1000);
    dockerConnector.setReadTimeout(0);
    dockerConnector.setConnectorType(JERSEY);
    dockerConnector.testConnection();

    //launcher
    final DockerComputerJNLPLauncher launcher = new DockerComputerJNLPLauncher();
    launcher.setNoCertificateCheck(true);
    launcher.setJvmOpts("-XX:-PrintClassHistogram");
    final DockerPullImage pullImage = new DockerPullImage();
    pullImage.setPullStrategy(PULL_LATEST);

    //remove
    final DockerRemoveContainer removeContainer = new DockerRemoveContainer();
    removeContainer.setRemoveVolumes(true);
    removeContainer.setForce(true);

    //lifecycle
    final DockerContainerLifecycle containerLifecycle = new DockerContainerLifecycle();
    containerLifecycle.setImage(slaveImage);
    containerLifecycle.setPullImage(pullImage);
    containerLifecycle.setRemoveContainer(removeContainer);

    //template
    final Entry entry = new Entry("super-key", TEST_VALUE);
    final EnvironmentVariablesNodeProperty nodeProperty = new EnvironmentVariablesNodeProperty(entry);

    final ArrayList<NodeProperty<?>> nodeProperties = new ArrayList<>();
    nodeProperties.add(nodeProperty);
    nodeProperties.add(new DockerNodeProperty(CONTAINER_ID, CLOUD_ID, DOCKER_HOST));


    final DockerSlaveTemplate slaveTemplate = new DockerSlaveTemplate();
    slaveTemplate.setMaxCapacity(4);
    slaveTemplate.setLabelString(DOCKER_CLOUD_LABEL);
    slaveTemplate.setLauncher(launcher);
    slaveTemplate.setMode(Node.Mode.EXCLUSIVE);
    slaveTemplate.setRetentionStrategy(new DockerOnceRetentionStrategy(10));
    slaveTemplate.setDockerContainerLifecycle(containerLifecycle);
    slaveTemplate.setNodeProperties(nodeProperties);

    final List<DockerSlaveTemplate> templates = new ArrayList<>();
    templates.add(slaveTemplate);

    final DockerCloud dockerCloud = new DockerCloud(
            DOCKER_CLOUD_NAME,
            templates,
            3,
            dockerConnector
    );
    jenkins.clouds.add(dockerCloud);
    jenkins.save(); // either xmls a half broken

    return true;
}
 
开发者ID:KostyaSha,项目名称:yet-another-docker-plugin,代码行数:81,代码来源:FreestyleTest.java


示例11: setVariables

import hudson.slaves.EnvironmentVariablesNodeProperty; //导入依赖的package包/类
protected void setVariables(Node node, EnvironmentVariablesNodeProperty.Entry... entries) throws IOException {
  node.getNodeProperties().replaceBy(
      Collections.singleton(new EnvironmentVariablesNodeProperty(
          entries)));

}
 
开发者ID:jenkinsci,项目名称:flaky-test-handler-plugin,代码行数:7,代码来源:AbstractGitTestCase.java



注:本文中的hudson.slaves.EnvironmentVariablesNodeProperty类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LinearDRPCTopologyBuilder类代码示例发布时间:2022-05-22
下一篇:
Java FileResourceLoader类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap