Search in sources :

Example 1 with NodePropertyDescriptor

use of hudson.slaves.NodePropertyDescriptor in project workflow-job-plugin by jenkinsci.

the class WorkflowRunTest method globalNodePropertiesInEnv.

@Test
@Issue("JENKINS-43396")
public void globalNodePropertiesInEnv() throws Exception {
    DescribableList<NodeProperty<?>, NodePropertyDescriptor> original = r.jenkins.getGlobalNodeProperties();
    EnvironmentVariablesNodeProperty envProp = new EnvironmentVariablesNodeProperty(new EnvironmentVariablesNodeProperty.Entry("KEY", "VALUE"));
    original.add(envProp);
    WorkflowJob j = r.jenkins.createProject(WorkflowJob.class, "envVars");
    j.setDefinition(new CpsFlowDefinition("echo \"KEY is ${env.KEY}\"", true));
    WorkflowRun b = r.assertBuildStatusSuccess(j.scheduleBuild2(0));
    r.assertLogContains("KEY is " + envProp.getEnvVars().get("KEY"), b);
}
Also used : NodePropertyDescriptor(hudson.slaves.NodePropertyDescriptor) CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) NodeProperty(hudson.slaves.NodeProperty) EnvironmentVariablesNodeProperty(hudson.slaves.EnvironmentVariablesNodeProperty) EnvironmentVariablesNodeProperty(hudson.slaves.EnvironmentVariablesNodeProperty) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test)

Example 2 with NodePropertyDescriptor

use of hudson.slaves.NodePropertyDescriptor in project hudson-2.x by hudson.

the class Functions method getNodePropertyDescriptors.

public static List<NodePropertyDescriptor> getNodePropertyDescriptors(Class<? extends Node> clazz) {
    List<NodePropertyDescriptor> result = new ArrayList<NodePropertyDescriptor>();
    Collection<NodePropertyDescriptor> list = (Collection) Hudson.getInstance().getDescriptorList(NodeProperty.class);
    for (NodePropertyDescriptor npd : list) {
        if (npd.isApplicable(clazz)) {
            result.add(npd);
        }
    }
    return result;
}
Also used : NodePropertyDescriptor(hudson.slaves.NodePropertyDescriptor) NodeProperty(hudson.slaves.NodeProperty) ArrayList(java.util.ArrayList) Collection(java.util.Collection)

Aggregations

NodeProperty (hudson.slaves.NodeProperty)2 NodePropertyDescriptor (hudson.slaves.NodePropertyDescriptor)2 EnvironmentVariablesNodeProperty (hudson.slaves.EnvironmentVariablesNodeProperty)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 CpsFlowDefinition (org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition)1 Test (org.junit.Test)1 Issue (org.jvnet.hudson.test.Issue)1