Search in sources :

Example 71 with EnvironmentVariableContext

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

the class ScmMaterialTest method shouldEscapeHyphenFromFolderNameWhenUsedInEnvVariable.

@Test
public void shouldEscapeHyphenFromFolderNameWhenUsedInEnvVariable() {
    EnvironmentVariableContext context = new EnvironmentVariableContext();
    material.setFolder("folder-name");
    material.setVariableWithName(context, "value", "GO_PROPERTY");
    assertThat(context.getProperty("GO_PROPERTY_FOLDER_NAME"), is("value"));
    assertThat(context.getProperty("GO_PROPERTY"), is(nullValue()));
}
Also used : EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) Test(org.junit.Test)

Example 72 with EnvironmentVariableContext

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

the class ScmMaterialTest method populateEnvironmentContextShouldSetFromAndToRevisionEnvironmentVariables.

@Test
public void populateEnvironmentContextShouldSetFromAndToRevisionEnvironmentVariables() {
    EnvironmentVariableContext ctx = new EnvironmentVariableContext();
    final ArrayList<Modification> modifications = new ArrayList<>();
    modifications.add(new Modification("user2", "comment2", "email2", new Date(), "24"));
    modifications.add(new Modification("user1", "comment1", "email1", new Date(), "23"));
    MaterialRevision materialRevision = new MaterialRevision(material, modifications);
    assertThat(ctx.getProperty(ScmMaterial.GO_FROM_REVISION), is(nullValue()));
    assertThat(ctx.getProperty(ScmMaterial.GO_TO_REVISION), is(nullValue()));
    assertThat(ctx.getProperty(ScmMaterial.GO_REVISION), is(nullValue()));
    material.populateEnvironmentContext(ctx, materialRevision, new File("."));
    assertThat(ctx.getProperty(ScmMaterial.GO_FROM_REVISION), is("23"));
    assertThat(ctx.getProperty(ScmMaterial.GO_TO_REVISION), is("24"));
    assertThat(ctx.getProperty(ScmMaterial.GO_REVISION), is("24"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) ArrayList(java.util.ArrayList) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) File(java.io.File) Date(java.util.Date) Test(org.junit.Test)

Example 73 with EnvironmentVariableContext

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

the class ScmMaterialTest method shouldEscapeHyphenFromMaterialNameWhenUsedInEnvVariable.

@Test
public void shouldEscapeHyphenFromMaterialNameWhenUsedInEnvVariable() {
    EnvironmentVariableContext context = new EnvironmentVariableContext();
    material.setName(new CaseInsensitiveString("material-name"));
    material.setVariableWithName(context, "value", "GO_PROPERTY");
    assertThat(context.getProperty("GO_PROPERTY_MATERIAL_NAME"), is("value"));
    assertThat(context.getProperty("GO_PROPERTY"), is(nullValue()));
}
Also used : EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 74 with EnvironmentVariableContext

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

the class P4MaterialTest method shouldAddServerSideEnvironmentVariablesClientNameEnvironmentVariable.

@Test
public void shouldAddServerSideEnvironmentVariablesClientNameEnvironmentVariable() throws IOException {
    File p4_working_dir = temporaryFolder.newFolder();
    P4Material p4 = new P4Material("host:10", "beautiful", "user");
    p4.setPassword("loser");
    EnvironmentVariableContext envVarCtx;
    envVarCtx = new EnvironmentVariableContext();
    p4.populateEnvironmentContext(envVarCtx, new MaterialRevision(p4, new Modification("loser", "loserish commit", "loser@boozer.com", new Date(), "123")), p4_working_dir);
    assertThat(envVarCtx.getProperty("GO_REVISION"), is("123"));
    assertThat(envVarCtx.getProperty("GO_TO_REVISION"), is("123"));
    assertThat(envVarCtx.getProperty("GO_FROM_REVISION"), is("123"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) File(java.io.File) Date(java.util.Date) Test(org.junit.Test)

Example 75 with EnvironmentVariableContext

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

the class P4MaterialTest method shouldSetGO_P4_CLIENT_toTheClientName.

@Test
public void shouldSetGO_P4_CLIENT_toTheClientName() {
    P4Material material = new P4Material("host:1234", "view", "username", "destination");
    EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
    File agentWorkingDirectory = new File("pipelines/pipeline-name");
    material.populateAgentSideEnvironmentContext(environmentVariableContext, agentWorkingDirectory);
    assertThat(environmentVariableContext.getProperty("GO_P4_CLIENT_DESTINATION"), is(material.clientName(material.workingdir(agentWorkingDirectory))));
}
Also used : EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) File(java.io.File) 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