use of hudson.slaves.NodeProperty 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);
}
use of hudson.slaves.NodeProperty in project workflow-job-plugin by jenkinsci.
the class WorkflowRun method getEnvironment.
@Override
public EnvVars getEnvironment(TaskListener listener) throws IOException, InterruptedException {
EnvVars env = super.getEnvironment(listener);
Jenkins instance = Jenkins.getInstance();
if (instance != null) {
for (NodeProperty nodeProperty : instance.getGlobalNodeProperties()) {
nodeProperty.buildEnvVars(env, listener);
}
}
// TODO EnvironmentContributingAction does not support Job yet:
ParametersAction a = getAction(ParametersAction.class);
if (a != null) {
for (ParameterValue v : a) {
v.buildEnvironment(this, env);
}
}
EnvVars.resolve(env);
return env;
}
use of hudson.slaves.NodeProperty in project configuration-as-code-plugin by jenkinsci.
the class JenkinsConfiguratorTest method shouldSetEnvironmentVariable.
@Test
@Issue("Issue #173")
@ConfiguredWithCode("SetEnvironmentVariable.yml")
public void shouldSetEnvironmentVariable() throws Exception {
final DescribableList<NodeProperty<?>, NodePropertyDescriptor> properties = Jenkins.get().getNodeProperties();
EnvVars env = new EnvVars();
for (NodeProperty<?> property : properties) {
property.buildEnvVars(env, TaskListener.NULL);
}
assertEquals("BAR", env.get("FOO"));
}
use of hudson.slaves.NodeProperty in project configuration-as-code-plugin by jenkinsci.
the class GlobalNodePropertiesTest method configure.
@Test
public void configure() {
final Jenkins jenkins = Jenkins.get();
DescribableList<NodeProperty<?>, NodePropertyDescriptor> nodeProperties = jenkins.getGlobalNodeProperties();
Set<Map.Entry<String, String>> entries = ((EnvironmentVariablesNodeProperty) nodeProperties.get(0)).getEnvVars().entrySet();
assertEquals(1, entries.size());
Map.Entry<String, String> envVar = entries.iterator().next();
assertEquals("FOO", envVar.getKey());
assertEquals("BAR", envVar.getValue());
}
Aggregations