use of org.jvnet.hudson.test.CaptureEnvironmentBuilder in project jenkins by jenkinsci.
the class SimpleBuildWrapperTest method envOverrideExpand.
@Test
public void envOverrideExpand() throws Exception {
Assume.assumeFalse(Functions.isWindows());
FreeStyleProject p = r.createFreeStyleProject();
p.getBuildWrappersList().add(new WrapperWithEnvOverrideExpand());
SpecialEnvSlave slave = new SpecialEnvSlave(tmp.getRoot(), r.createComputerLauncher(null));
r.jenkins.addNode(slave);
p.setAssignedNode(slave);
JDK jdk = new JDK("test", "/opt/jdk");
r.jenkins.getJDKs().add(jdk);
p.setJDK(jdk);
CaptureEnvironmentBuilder captureEnvironment = new CaptureEnvironmentBuilder();
p.getBuildersList().add(captureEnvironment);
p.getBuildersList().add(new Shell("echo effective PATH=$PATH"));
FreeStyleBuild b = r.buildAndAssertSuccess(p);
String expected = "/home/jenkins/extra/bin:/opt/jdk/bin:/usr/bin:/bin";
assertEquals(expected, captureEnvironment.getEnvVars().get("PATH"));
// TODO why is /opt/jdk/bin added twice? In CommandInterpreter.perform, envVars right before Launcher.launch is correct, but this somehow sneaks in.
r.assertLogContains("effective PATH=/opt/jdk/bin:" + expected, b);
}
use of org.jvnet.hudson.test.CaptureEnvironmentBuilder in project jenkins by jenkinsci.
the class BuiltInNodeMigrationTest method assertStatus.
public static void assertStatus(JenkinsRule j, boolean migrationDoneGetterValue, Boolean migrationNeededFieldValue, String label, String nodeName) throws Exception {
assertEquals(migrationDoneGetterValue, j.jenkins.getRenameMigrationDone());
assertEquals(migrationNeededFieldValue, j.jenkins.nodeRenameMigrationNeeded);
assertEquals(new LabelAtom(label), j.jenkins.getSelfLabel());
final FreeStyleProject freeStyleProject = j.createFreeStyleProject();
final CaptureEnvironmentBuilder environmentBuilder = new CaptureEnvironmentBuilder();
freeStyleProject.getBuildersList().add(environmentBuilder);
j.buildAndAssertSuccess(freeStyleProject);
assertEquals(nodeName, environmentBuilder.getEnvVars().get("NODE_NAME"));
}
use of org.jvnet.hudson.test.CaptureEnvironmentBuilder in project jenkins by jenkinsci.
the class EnvironmentContributorTest method projectScoped.
/**
* Makes sure that the project-scoped environment variables are getting
* consulted.
*/
@Test
public void projectScoped() throws Exception {
FreeStyleProject p = j.createFreeStyleProject();
CaptureEnvironmentBuilder c = new CaptureEnvironmentBuilder();
p.getBuildersList().add(c);
p.setDescription("Issac Newton");
j.buildAndAssertSuccess(p);
assertEquals("Issac Newton", c.getEnvVars().get("ABC"));
assertEquals("built-in", c.getEnvVars().get("NODE_NAME"));
}
use of org.jvnet.hudson.test.CaptureEnvironmentBuilder in project jenkins by jenkinsci.
the class ParametersTest method sensitiveParameters.
@Test
public void sensitiveParameters() throws Exception {
FreeStyleProject project = j.createFreeStyleProject();
ParametersDefinitionProperty pdb = new ParametersDefinitionProperty(new PasswordParameterDefinition("password", "12345", "password description"));
project.addProperty(pdb);
CaptureEnvironmentBuilder builder = new CaptureEnvironmentBuilder();
project.getBuildersList().add(builder);
FreeStyleBuild build = j.buildAndAssertSuccess(project);
Set<String> sensitiveVars = build.getSensitiveBuildVariables();
assertNotNull(sensitiveVars);
assertTrue(sensitiveVars.contains("password"));
}
use of org.jvnet.hudson.test.CaptureEnvironmentBuilder in project jenkins by jenkinsci.
the class ParametersTest method nonSensitiveParameters.
@Test
public void nonSensitiveParameters() throws Exception {
FreeStyleProject project = j.createFreeStyleProject();
ParametersDefinitionProperty pdb = new ParametersDefinitionProperty(new StringParameterDefinition("string", "defaultValue", "string description"));
project.addProperty(pdb);
CaptureEnvironmentBuilder builder = new CaptureEnvironmentBuilder();
project.getBuildersList().add(builder);
FreeStyleBuild build = j.buildAndAssertSuccess(project);
Set<String> sensitiveVars = build.getSensitiveBuildVariables();
assertNotNull(sensitiveVars);
assertFalse(sensitiveVars.contains("string"));
}
Aggregations