use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.
the class BuildAssignmentTest method shouldInitializeEnvironmentContextFromJobPlan.
@Test
public void shouldInitializeEnvironmentContextFromJobPlan() throws Exception {
DefaultJobPlan defaultJobPlan = jobForPipeline("foo");
EnvironmentVariables variables = new EnvironmentVariables();
variables.add("key1", "value1");
variables.add("key2", "value2");
defaultJobPlan.setVariables(variables);
BuildAssignment buildAssignment = BuildAssignment.create(defaultJobPlan, BuildCause.createManualForced(), new ArrayList<>(), null, null, new ArtifactStores());
EnvironmentVariableContext context = buildAssignment.initialEnvironmentVariableContext();
assertThat(context.getProperties().size(), is(9));
assertThat(context.getProperty("key1"), is("value1"));
assertThat(context.getProperty("key2"), is("value2"));
}
use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.
the class BuildWorkArtifactUploadingTest method createAssignment.
private BuildAssignment createAssignment(List<ArtifactPlan> artifactPlans, String[] fileToCreate) throws IOException {
MaterialRevisions materialRevisions = materialRevisions();
BuildCause buildCause = BuildCause.createWithModifications(materialRevisions, "");
List<Builder> builders = new ArrayList<>();
builders.add(new CreateFileBuilder(fileToCreate));
DefaultJobPlan plan = new DefaultJobPlan(new Resources(), artifactPlans, new ArrayList<>(), -1, new JobIdentifier(PIPELINE_NAME, -2, "1", STAGE_NAME, "1", JOB_NAME), null, new EnvironmentVariables(), new EnvironmentVariables(), null);
return BuildAssignment.create(plan, buildCause, builders, buildWorkingDirectory, new EnvironmentVariableContext(), new ArtifactStores());
}
use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.
the class BuildWorkArtifactUploadingTest method setUp.
@Before
public void setUp() throws IOException {
initMocks(this);
buildWorkingDirectory = new File("tmp" + UUID.randomUUID());
environmentVariableContext = new EnvironmentVariableContext();
svnRepoFixture = new SvnRepoFixture("../common/src/test/resources/data/svnrepo", temporaryFolder);
svnRepoFixture.createRepository();
SvnCommand command = new SvnCommand(null, svnRepoFixture.getEnd2EndRepoUrl());
PipelineConfigMother.createPipelineConfig(PIPELINE_NAME, STAGE_NAME, JOB_NAME);
svnMaterial = SvnMaterial.createSvnMaterialWithMock(command);
new SystemEnvironment().setProperty("serviceUrl", "some_random_place");
}
use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.
the class BuildWorkEnvironmentVariablesTest method shouldSetUpEnvironmentContextCorrectly.
@Test
public void shouldSetUpEnvironmentContextCorrectly() throws Exception {
new SystemEnvironment().setProperty("serviceUrl", "some_random_place");
Materials materials = new Materials(svnMaterial);
EnvironmentVariableContext environmentVariableContext = doWorkWithMaterials(materials);
assertThat(environmentVariableContext.getProperty("GO_REVISION"), is("3"));
assertThat(environmentVariableContext.getProperty("GO_SERVER_URL"), is("some_random_place"));
assertThat(environmentVariableContext.getProperty("GO_PIPELINE_NAME"), is(PIPELINE_NAME));
assertThat(environmentVariableContext.getProperty("GO_PIPELINE_LABEL"), is("1"));
assertThat(environmentVariableContext.getProperty("GO_STAGE_NAME"), is(STAGE_NAME));
assertThat(environmentVariableContext.getProperty("GO_STAGE_COUNTER"), is("1"));
assertThat(environmentVariableContext.getProperty("GO_JOB_NAME"), is(JOB_NAME));
assertThat(environmentVariableContext.getProperty("GO_TRIGGER_USER"), is(TRIGGERED_BY_USER));
}
use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.
the class BuildWorkEnvironmentVariablesTest method doWorkWithMaterials.
private EnvironmentVariableContext doWorkWithMaterials(Materials materials) throws IOException {
pipelineConfig.setMaterialConfigs(materials.convertToConfigs());
BuildAssignment buildAssigment = createAssignment(null);
BuildWork work = new BuildWork(buildAssigment, systemEnvironment.consoleLogCharset());
EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
AgentIdentifier agentIdentifier = new AgentIdentifier("somename", "127.0.0.1", AGENT_UUID);
work.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, new FakeBuildRepositoryRemote(), new GoArtifactsManipulatorStub(), new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), packageRepositoryExtension, scmExtension, taskExtension, null, null));
return environmentVariableContext;
}
Aggregations