use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.
the class MaterialRevisionsTest method shouldPopulateEnvironmentVariablesForEachOfTheMaterialsWithTheValueForChangedFlag.
@Test
public void shouldPopulateEnvironmentVariablesForEachOfTheMaterialsWithTheValueForChangedFlag() {
EnvironmentVariableContext context = new EnvironmentVariableContext();
MaterialRevisions revisions = new MaterialRevisions();
revisions.addRevision(new MaterialRevision(MaterialsMother.hgMaterial("empty-dest-and-no-name", null), true, ModificationsMother.multipleModificationList()));
revisions.addRevision(new MaterialRevision(MaterialsMother.hgMaterial("url", "hg-folder1"), true, ModificationsMother.multipleModificationList()));
revisions.addRevision(new MaterialRevision(MaterialsMother.hgMaterial("url", "hg-folder2"), false, ModificationsMother.multipleModificationList()));
revisions.addRevision(new MaterialRevision(MaterialsMother.dependencyMaterial("p1", "s1"), true, ModificationsMother.changedDependencyMaterialRevision("p3", 1, "1", "s", 1, new Date()).getModifications()));
revisions.addRevision(new MaterialRevision(MaterialsMother.dependencyMaterial("p2", "s2"), false, ModificationsMother.changedDependencyMaterialRevision("p3", 1, "1", "s", 1, new Date()).getModifications()));
revisions.addRevision(new MaterialRevision(MaterialsMother.pluggableSCMMaterial("scm1", "scm1name"), true, ModificationsMother.multipleModificationList()));
revisions.addRevision(new MaterialRevision(MaterialsMother.pluggableSCMMaterial("scm2", "scm2name"), false, ModificationsMother.multipleModificationList()));
revisions.addRevision(new MaterialRevision(MaterialsMother.packageMaterial("repo1", "repo1name", "pkg1", "pkg1name"), true, ModificationsMother.multipleModificationList()));
revisions.addRevision(new MaterialRevision(MaterialsMother.packageMaterial("repo2", "repo2name", "pkg2", "pkg2name"), false, ModificationsMother.multipleModificationList()));
revisions.populateEnvironmentVariables(context, null);
assertThat(context.getProperty("GO_MATERIAL_HAS_CHANGED"), is("true"));
assertThat(context.getProperty("GO_MATERIAL_HG_FOLDER1_HAS_CHANGED"), is("true"));
assertThat(context.getProperty("GO_MATERIAL_HG_FOLDER2_HAS_CHANGED"), is("false"));
assertThat(context.getProperty("GO_MATERIAL_P1_HAS_CHANGED"), is("true"));
assertThat(context.getProperty("GO_MATERIAL_P2_HAS_CHANGED"), is("false"));
assertThat(context.getProperty("GO_MATERIAL_SCM1NAME_HAS_CHANGED"), is("true"));
assertThat(context.getProperty("GO_MATERIAL_SCM2NAME_HAS_CHANGED"), is("false"));
assertThat(context.getProperty("GO_MATERIAL_REPO1NAME_PKG1NAME_HAS_CHANGED"), is("true"));
assertThat(context.getProperty("GO_MATERIAL_REPO2NAME_PKG2NAME_HAS_CHANGED"), is("false"));
}
use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.
the class ProcessManagerTest method shouldAddToProcessListWhenNewProcessCreated.
@Test
public void shouldAddToProcessListWhenNewProcessCreated() {
processManager.createProcess(new String[] { "echo", "message" }, "echo 'message'", null, new HashMap<>(), new EnvironmentVariableContext(), inMemoryConsumer(), "test-tag", "utf-8", "ERROR: ");
assertThat(processManager.getProcessMap().size(), is(3));
}
use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.
the class JobIdentifierTest method shouldPopulateGoJobInstanceRelatedEnvironmentVariables.
@Test
public void shouldPopulateGoJobInstanceRelatedEnvironmentVariables() {
JobIdentifier id = new JobIdentifier("pipeline-name", 10, "label-10", "stage-name", "2", "build-name");
id.setRerunOfCounter(1);
EnvironmentVariableContext context = new EnvironmentVariableContext();
id.populateEnvironmentVariables(context);
EnvironmentVariableContext expected = new EnvironmentVariableContext();
expected.setProperty("GO_PIPELINE_NAME", "pipeline-name", false);
expected.setProperty("GO_PIPELINE_COUNTER", "10", false);
expected.setProperty("GO_PIPELINE_LABEL", "label-10", false);
expected.setProperty("GO_STAGE_NAME", "stage-name", false);
expected.setProperty("GO_STAGE_COUNTER", "2", false);
expected.setProperty("GO_RERUN_OF_STAGE_COUNTER", "1", false);
expected.setProperty("GO_JOB_NAME", "build-name", false);
assertThat(context, is(expected));
}
use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.
the class JobIdentifierTest method shouldNotPopulate_RerunOfStage_whenNotAvailable.
@Test
public void shouldNotPopulate_RerunOfStage_whenNotAvailable() {
JobIdentifier id = new JobIdentifier("pipeline-name", 10, "label-10", "stage-name", "2", "build-name");
EnvironmentVariableContext context = new EnvironmentVariableContext();
id.populateEnvironmentVariables(context);
assertThat(context.hasProperty("GO_RERUN_OF_STAGE_COUNTER"), is(false));
id.setRerunOfCounter(1);
context = new EnvironmentVariableContext();
id.populateEnvironmentVariables(context);
assertThat(context.hasProperty("GO_RERUN_OF_STAGE_COUNTER"), is(true));
}
use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.
the class BuildComposer method environmentVariableContext.
private EnvironmentVariableContext environmentVariableContext() {
EnvironmentVariableContext context = new EnvironmentVariableContext();
context.addAll(assignment.initialEnvironmentVariableContext());
return context;
}
Aggregations