Search in sources :

Example 1 with EnvironmentVariablesNodeProperty

use of hudson.slaves.EnvironmentVariablesNodeProperty 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 EnvironmentVariablesNodeProperty

use of hudson.slaves.EnvironmentVariablesNodeProperty in project sonar-scanner-jenkins by SonarSource.

the class MsBuildSQRunnerBeginTest method addEnvVar.

private void addEnvVar(String key, String value) {
    EnvironmentVariablesNodeProperty prop = new EnvironmentVariablesNodeProperty();
    EnvVars envVars = prop.getEnvVars();
    envVars.put(key, value);
    j.jenkins.getGlobalNodeProperties().add(prop);
}
Also used : EnvVars(hudson.EnvVars) EnvironmentVariablesNodeProperty(hudson.slaves.EnvironmentVariablesNodeProperty)

Example 3 with EnvironmentVariablesNodeProperty

use of hudson.slaves.EnvironmentVariablesNodeProperty 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());
}
Also used : Jenkins(jenkins.model.Jenkins) NodePropertyDescriptor(hudson.slaves.NodePropertyDescriptor) EnvironmentVariablesNodeProperty(hudson.slaves.EnvironmentVariablesNodeProperty) NodeProperty(hudson.slaves.NodeProperty) Util.toYamlString(io.jenkins.plugins.casc.misc.Util.toYamlString) Map(java.util.Map) Test(org.junit.Test)

Example 4 with EnvironmentVariablesNodeProperty

use of hudson.slaves.EnvironmentVariablesNodeProperty in project htmlpublisher-plugin by jenkinsci.

the class HtmlPublisherIntegrationTest method addEnvironmentVariable.

private void addEnvironmentVariable(String key, String value) {
    EnvironmentVariablesNodeProperty prop = new EnvironmentVariablesNodeProperty();
    EnvVars envVars = prop.getEnvVars();
    envVars.put(key, value);
    j.jenkins.getGlobalNodeProperties().add(prop);
}
Also used : EnvVars(hudson.EnvVars) EnvironmentVariablesNodeProperty(hudson.slaves.EnvironmentVariablesNodeProperty)

Example 5 with EnvironmentVariablesNodeProperty

use of hudson.slaves.EnvironmentVariablesNodeProperty in project phabricator-jenkins-plugin by uber.

the class TestUtils method setEnvironmentVariables.

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);
}
Also used : EnvVars(hudson.EnvVars) EnvironmentVariablesNodeProperty(hudson.slaves.EnvironmentVariablesNodeProperty)

Aggregations

EnvironmentVariablesNodeProperty (hudson.slaves.EnvironmentVariablesNodeProperty)5 EnvVars (hudson.EnvVars)3 NodeProperty (hudson.slaves.NodeProperty)2 NodePropertyDescriptor (hudson.slaves.NodePropertyDescriptor)2 Test (org.junit.Test)2 Util.toYamlString (io.jenkins.plugins.casc.misc.Util.toYamlString)1 Map (java.util.Map)1 Jenkins (jenkins.model.Jenkins)1 CpsFlowDefinition (org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition)1 Issue (org.jvnet.hudson.test.Issue)1