Search in sources :

Example 21 with EnvironmentVariableContext

use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.

the class BuildWorkEnvironmentVariablesTest method setUp.

@Before
public void setUp() throws Exception {
    initMocks(this);
    dir = temporaryFolder.newFolder("someFolder");
    environmentVariableContext = new EnvironmentVariableContext();
    svnRepoFixture = new SvnRepoFixture("../common/src/test/resources/data/svnrepo", temporaryFolder);
    svnRepoFixture.createRepository();
    command = new SvnCommand(null, svnRepoFixture.getEnd2EndRepoUrl());
    pipelineConfig = PipelineConfigMother.createPipelineConfig(PIPELINE_NAME, STAGE_NAME, JOB_NAME);
    svnMaterial = SvnMaterial.createSvnMaterialWithMock(command);
    dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("upstream1"), new CaseInsensitiveString(STAGE_NAME));
    dependencyMaterialWithName = new DependencyMaterial(new CaseInsensitiveString("upstream2"), new CaseInsensitiveString(STAGE_NAME));
    dependencyMaterialWithName.setName(new CaseInsensitiveString("dependency_material_name"));
    setupHgRepo();
    p4Fixture = new P4Fixture();
    p4Material = getP4Material();
}
Also used : P4Fixture(com.thoughtworks.go.domain.materials.perforce.P4Fixture) SvnCommand(com.thoughtworks.go.domain.materials.svn.SvnCommand) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) SvnRepoFixture(com.thoughtworks.go.utils.SvnRepoFixture) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Before(org.junit.Before)

Example 22 with EnvironmentVariableContext

use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.

the class BuildersTest method shouldNotBuildIfTheJobIsCanceled.

@Test
public void shouldNotBuildIfTheJobIsCanceled() throws Exception {
    StubGoPublisher goPublisher = new StubGoPublisher();
    EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
    CommandBuilder builder = new CommandBuilder("echo", "hello", new File("."), new RunIfConfigs(FAILED), new com.thoughtworks.go.domain.builder.StubBuilder(), "");
    Builders builders = new Builders(Collections.singletonList(builder), goPublisher, null, null, null);
    builders.setIsCancelled(true);
    builders.build(environmentVariableContext, "utf-8");
    assertThat(goPublisher.getMessage(), is(""));
}
Also used : StubGoPublisher(com.thoughtworks.go.domain.StubGoPublisher) RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) StubBuilder(com.thoughtworks.go.domain.builder.StubBuilder) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) File(java.io.File) Test(org.junit.Test)

Example 23 with EnvironmentVariableContext

use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.

the class BuildersTest method shouldNotSetAsCurrentBuilderIfNotRun.

@Test
public void shouldNotSetAsCurrentBuilderIfNotRun() throws Exception {
    EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
    Builder builder = new CommandBuilder("echo", "", new File("."), new RunIfConfigs(FAILED), null, "");
    Builders builders = new Builders(Collections.singletonList(builder), null, null, null, null);
    builders.setIsCancelled(true);
    builders.build(environmentVariableContext, "utf-8");
    Builders expected = new Builders(Collections.singletonList(builder), null, null, null, null);
    expected.setIsCancelled(true);
    assertThat(builders, is(expected));
}
Also used : CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) Builder(com.thoughtworks.go.domain.builder.Builder) StubBuilder(com.thoughtworks.go.domain.builder.StubBuilder) RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) File(java.io.File) Test(org.junit.Test)

Example 24 with EnvironmentVariableContext

use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.

the class BuildersTest method shouldNotCancelAnythingIfAllBuildersHaveRun.

@Test
public void shouldNotCancelAnythingIfAllBuildersHaveRun() throws Exception {
    EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
    Builder builder = new StubBuilder(new RunIfConfigs(ANY));
    Builders builders = new Builders(Collections.singletonList(builder), new StubGoPublisher(), null, null, null);
    builders.build(environmentVariableContext, "utf-8");
    builders.cancel(environmentVariableContext, "utf-8");
}
Also used : StubGoPublisher(com.thoughtworks.go.domain.StubGoPublisher) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) Builder(com.thoughtworks.go.domain.builder.Builder) StubBuilder(com.thoughtworks.go.domain.builder.StubBuilder) RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) StubBuilder(com.thoughtworks.go.domain.builder.StubBuilder) Test(org.junit.Test)

Example 25 with EnvironmentVariableContext

use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.

the class EnvironmentVariableContextTest method shouldPopulateEnvironmentForMaterialUsingDest.

@Test
public void shouldPopulateEnvironmentForMaterialUsingDest() throws IOException {
    SvnMaterial svn = MaterialsMother.svnMaterial();
    svn.setFolder("svn-dir");
    MaterialRevision revision = new MaterialRevision(svn, ModificationsMother.oneModifiedFile("revision1"));
    MaterialRevisions materialRevisions = new MaterialRevisions(revision);
    EnvironmentVariableContext context = new EnvironmentVariableContext();
    context.setProperty("GO_SERVER_URL", SystemEnvironment.getProperty("serviceUrl"), false);
    jobIdentifier().populateEnvironmentVariables(context);
    materialRevisions.populateEnvironmentVariables(context, temporaryFolder.newFolder());
    assertThat(context.getProperty("GO_REVISION_SVN_DIR"), is("revision1"));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) Test(org.junit.Test)

Aggregations

EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)94 Test (org.junit.Test)74 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)19 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)16 File (java.io.File)14 Date (java.util.Date)13 Modification (com.thoughtworks.go.domain.materials.Modification)12 Modifications (com.thoughtworks.go.domain.materials.Modifications)10 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)9 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)9 Before (org.junit.Before)8 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)7 ArtifactStores (com.thoughtworks.go.config.ArtifactStores)6 Materials (com.thoughtworks.go.config.materials.Materials)6 Builder (com.thoughtworks.go.domain.builder.Builder)6 HashMap (java.util.HashMap)6 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)5 RunIfConfigs (com.thoughtworks.go.domain.RunIfConfigs)5 PackageMaterialRevision (com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialRevision)5 PluggableSCMMaterialRevision (com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision)5